Skip to content

Commit 337a6f4

Browse files
committed
fix(previewer): --fixed-strings with custom rg_glob_fn
1 parent d99996b commit 337a6f4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lua/fzf-lua/previewer/builtin.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,23 @@ function Previewer.base:maybe_set_cursorline(win, pos)
10081008
end
10091009

10101010
function Previewer.buffer_or_file:set_cursor_hl(entry)
1011-
local mgrep = require("fzf-lua.providers.grep")
1011+
local mgrep, glob_args = require("fzf-lua.providers.grep"), nil
10121012
local regex = self.opts.__ACT_TO == mgrep.grep and self.opts._last_query
10131013
or self.opts.__ACT_TO == mgrep.live_grep and self.opts.search or nil
10141014
if regex and self.opts.rg_glob and self.opts.glob_separator then
1015-
regex = require("fzf-lua.make_entry").glob_parse(regex, self.opts)
1015+
regex, glob_args = require("fzf-lua.make_entry").glob_parse(regex, self.opts)
10161016
end
1017-
if regex and self.opts.cmd
1018-
and (self.opts.cmd:match("%-%-fixed%-strings") or self.opts.cmd:match("%-F")) then
1019-
regex = utils.rg_escape(regex)
1017+
if regex then
1018+
(function()
1019+
-- Check both the cmd and glob_args in case the user has a custom
1020+
-- `rg_glob_fn` which uses raw args (as the wiki example)
1021+
local strs = { self.opts.cmd, glob_args }
1022+
for _, s in ipairs(strs) do
1023+
if s and (s:match("%-%-fixed%-strings") or s:match("%-F")) then
1024+
regex = utils.rg_escape(regex)
1025+
end
1026+
end
1027+
end)()
10201028
end
10211029

10221030
-- If called from tags previewer, can happen when using ctags cmd

0 commit comments

Comments
 (0)