Skip to content

Commit

Permalink
fix(grep): regex escape newline (closes #1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed May 19, 2024
1 parent 53698d7 commit 677055f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/fzf-lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,14 @@ end
---@return string
function M.rg_escape(str)
if not str then return str end
-- [(~'"\/$?'`*&&||;[]<>)]
-- escape "\~$?*|[()^-."
-- [(~'"\/$?'`*&&||;[]<>)]
-- escape "\~$?*|[()^-."
local ret = str:gsub("[\\~$?*|{\\[()^%-%.%+]", function(x)
return "\\" .. x
end)
return "\\" .. x
end)
-- Escape newline (#1203) at the end so we
-- don't end up escaping the backslash twice
:gsub("\n", "\\n")
return ret
end

Expand Down

0 comments on commit 677055f

Please sign in to comment.