Skip to content

Commit c5d53ee

Browse files
committed
fix(grep): auto-detect -n|--column (close #1688)
1 parent 3746d5e commit c5d53ee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lua/fzf-lua/providers/grep.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ local get_grep_cmd = function(opts, search_query, no_esc)
106106
for _, flags in ipairs(bin2flags[bin] or {}) do
107107
local has_flag_group
108108
for _, f in ipairs(flags) do
109-
if command:match(utils.lua_regex_escape(f)) then
109+
if command:match("^" .. utils.lua_regex_escape(f))
110+
or command:match("%s+" .. utils.lua_regex_escape(f))
111+
then
110112
has_flag_group = true
111113
end
112114
end
@@ -116,8 +118,8 @@ local get_grep_cmd = function(opts, search_query, no_esc)
116118
"Added missing '%s' flag to '%s'. Add 'silent=true' to hide this message.",
117119
table.concat(flags, "|"), bin))
118120
end
121+
command = make_entry.rg_insert_args(command, flags[1])
119122
end
120-
command = make_entry.rg_insert_args(command, flags[1])
121123
end
122124
end
123125

0 commit comments

Comments
 (0)