Skip to content

Commit 4ca7a9c

Browse files
committed
Fix don't quote prompt when quote_char is empty string
I already have a keymap to quote the prompt, so my current workflow is: type query-> Quote prompt -> Start adding options However I would like to create keymaps for some common options I use, currently this not possible because when `quote_char` is emtpy, it still adds backslashes before each character in prompt, and this breaks the search pattern Usecase is for chaining mulitple `rg` options without, quoting the prompt mulitple times, which is not the expected behavior when `quote_char` is empty string. E.g Consider this keymap ```lua ["<C-;>"] = require("telescope-live-grep-args.actions").quote_prompt { postfix = " --word-regexp ", quote_char = "", } ``` And I search for `tab`, then pressing `<C-;>`: Before: ``` \"\t\a\b\"\ --word-regexp ``` After: ``` "tab" --word-regexp ```
1 parent 0f75ea8 commit 4ca7a9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lua/telescope-live-grep-args/actions/quote_prompt.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ return function (opts)
2121
if opts.trim then
2222
prompt = vim.trim(prompt)
2323
end
24-
prompt = helpers.quote(prompt, { quote_char = opts.quote_char }) .. opts.postfix
24+
if opts.quote_char == "" then
25+
prompt = prompt .. opts.postfix
26+
else
27+
prompt = helpers.quote(prompt, { quote_char = opts.quote_char }) .. opts.postfix
28+
end
2529
picker:set_prompt(prompt)
2630
end
2731
end

0 commit comments

Comments
 (0)