From 1086bc42862e9a3e485ca429afc7858ddda215c2 Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:52:40 +0200 Subject: [PATCH] fix: `autoBraceSimpleCaptureGroups` for multi-digits like `$19` --- lua/rip-substitute/rg-operations.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/rip-substitute/rg-operations.lua b/lua/rip-substitute/rg-operations.lua index 3c831ef..28930b7 100644 --- a/lua/rip-substitute/rg-operations.lua +++ b/lua/rip-substitute/rg-operations.lua @@ -34,7 +34,8 @@ function M.getSearchAndReplaceValuesFromPopup() local toSearch, toReplace = unpack(vim.api.nvim_buf_get_lines(state.popupBufNr, 0, -1, false)) if config.regexOptions.autoBraceSimpleCaptureGroups then - toReplace = toReplace:gsub("%$(%d+)", "${%1}") + -- CAVEAT will not work if user has 10 capture groups (which should almost never happen though) + toReplace = toReplace:gsub("%$(%d)", "${%1}") end return toSearch, toReplace end