Skip to content

Commit 3d52a8e

Browse files
committed
fix: quotes highlight.
1 parent 16ab1b2 commit 3d52a8e

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

lua/telescope-live-grep-args/helpers.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ M.quote = function(value, opts)
1616
return opts.quote_char .. quoted .. opts.quote_char
1717
end
1818

19-
return M
19+
M.extract_quotes = function(input)
20+
local match = input:match('"(.-)"')
21+
if match then
22+
return match
23+
else
24+
return input
25+
end
26+
end
27+
28+
return M

lua/telescope-live-grep-args/prompt_parser.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ M.parse = function(prompt, autoquote)
134134
end
135135

136136
frag = frag or ''
137-
137+
138138
if current_arg == nil then
139139
current_arg = frag
140140
else

lua/telescope/_extensions/live_grep_args.lua

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
--
33
-- SPDX-License-Identifier: MIT
44

5+
local helpers = require("telescope-live-grep-args.helpers")
56
local prompt_parser = require("telescope-live-grep-args.prompt_parser")
67

78
local pickers = require("telescope.pickers")
@@ -38,6 +39,8 @@ local live_grep_args = function(opts)
3839
end
3940
end
4041

42+
local picker
43+
4144
local cmd_generator = function(prompt)
4245
if not prompt or prompt == "" then
4346
return nil
@@ -61,22 +64,32 @@ local live_grep_args = function(opts)
6164
end
6265
end
6366

64-
pickers
65-
.new(opts, {
66-
prompt_title = "Live Grep (Args)",
67-
finder = finders.new_job(cmd_generator, opts.entry_maker, opts.max_results, opts.cwd),
68-
previewer = conf.grep_previewer(opts),
69-
sorter = sorters.highlighter_only(opts),
70-
attach_mappings = function(_, map)
71-
for mode, mappings in pairs(opts.mappings) do
72-
for key, action in pairs(mappings) do
73-
map(mode, key, action)
74-
end
67+
picker = pickers.new(opts, {
68+
prompt_title = "Live Grep (Args)",
69+
finder = finders.new_job(cmd_generator, opts.entry_maker, opts.max_results, opts.cwd),
70+
previewer = conf.grep_previewer(opts),
71+
sorter = (opts.custom_sorter and opts.custom_sorter or sorters.highlighter_only(opts)),
72+
attach_mappings = function(_, map)
73+
for mode, mappings in pairs(opts.mappings) do
74+
for key, action in pairs(mappings) do
75+
map(mode, key, action)
7576
end
76-
return true
77-
end,
78-
})
79-
:find()
77+
end
78+
return true
79+
end,
80+
})
81+
82+
local org_highligh_on_row = picker.highlight_one_row
83+
picker.highlight_one_row = function(...)
84+
local args = { ... }
85+
assert(#args == 5, 'invalid argment declation')
86+
87+
args[3] = picker._get_prompt(picker)
88+
89+
org_highligh_on_row(table.unpack(args))
90+
end
91+
92+
picker:find()
8093
end
8194

8295
return telescope.register_extension({

0 commit comments

Comments
 (0)