From 0f87ed5dfed5dda69319d927513f262b0fcfcca0 Mon Sep 17 00:00:00 2001 From: Rafael Madriz Date: Sun, 28 May 2023 10:43:24 -0300 Subject: [PATCH] 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 [""] = require("telescope-live-grep-args.actions").quote_prompt { postfix = " --word-regexp ", quote_char = "", } ``` And I search for `tab`, then pressing ``: Before: ``` \"\t\a\b\"\ --word-regexp ``` After: ``` "tab" --word-regexp ``` --- lua/telescope-live-grep-args/actions/quote_prompt.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/telescope-live-grep-args/actions/quote_prompt.lua b/lua/telescope-live-grep-args/actions/quote_prompt.lua index 1981314..5c7b672 100644 --- a/lua/telescope-live-grep-args/actions/quote_prompt.lua +++ b/lua/telescope-live-grep-args/actions/quote_prompt.lua @@ -21,7 +21,11 @@ return function (opts) if opts.trim then prompt = vim.trim(prompt) end - prompt = helpers.quote(prompt, { quote_char = opts.quote_char }) .. opts.postfix + if opts.quote_char == '' then + prompt = prompt .. opts.postfix + else + prompt = helpers.quote(prompt, { quote_char = opts.quote_char }) .. opts.postfix + end picker:set_prompt(prompt) end end