diff --git a/lua/fzf-lua/make_entry.lua b/lua/fzf-lua/make_entry.lua index cb56825..e273725 100644 --- a/lua/fzf-lua/make_entry.lua +++ b/lua/fzf-lua/make_entry.lua @@ -235,6 +235,8 @@ M.preprocess = function(opts) glob_args = glob_args .. ("%s %s ") :format(opts.glob_flag, vim.fn.shellescape(s)) end + -- gsub doesn't like single % on rhs + search_query = search_query:gsub("%%", "%%%%") -- reset argvz so it doesn't get replaced again below opts.cmd = opts.cmd:gsub(argvz, glob_args .. vim.fn.shellescape(search_query)) diff --git a/lua/fzf-lua/providers/grep.lua b/lua/fzf-lua/providers/grep.lua index 3389e50..ed8ed42 100644 --- a/lua/fzf-lua/providers/grep.lua +++ b/lua/fzf-lua/providers/grep.lua @@ -267,7 +267,7 @@ M.live_grep_mt = function(opts) opts.fzf_fn = {} if opts.exec_empty_query or (opts.search and #opts.search > 0) then opts.fzf_fn = initial_command:gsub(placeholder, - libuv.shellescape(query)) + libuv.shellescape(query:gsub("%%", "%%%%"))) end opts.fzf_opts['--phony'] = '' opts.fzf_opts['--query'] = libuv.shellescape(query) diff --git a/lua/fzf-lua/utils.lua b/lua/fzf-lua/utils.lua index fe8039b..4ff94ed 100644 --- a/lua/fzf-lua/utils.lua +++ b/lua/fzf-lua/utils.lua @@ -103,8 +103,8 @@ end function M.rg_escape(str) if not str then return str end -- [(~'"\/$?'`*&&||;[]<>)] - -- escape "\~$?*|[()-^" - return str:gsub('[\\~$?*|{\\[()%-^]', function(x) + -- escape "\~$?*|[()^-." + return str:gsub('[\\~$?*|{\\[()^%-%.]', function(x) return '\\' .. x end) end