Skip to content

Commit

Permalink
fix(FZF_DEFAULT_OPTS): strip --preview-window (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Mar 28, 2024
1 parent 618c4de commit 348cb6b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lua/fzf-lua/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,23 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
["SHELL"] = shell_cmd[1],
["FZF_DEFAULT_COMMAND"] = FZF_DEFAULT_COMMAND,
["SKIM_DEFAULT_COMMAND"] = FZF_DEFAULT_COMMAND,
["FZF_DEFAULT_OPTS"] = (function()
-- Newer style `--preview-window` options in FZF_DEFAULT_OPTS such as:
-- --preview-window "right,50%,hidden,<60(up,70%,hidden)"
-- prevents our previewer from working properly, since there is never
-- a reason to inherit `preview-window` options it can be safely stripped
-- from FZF_DEFAULT_OPTS (#1107)
local default_opts = os.getenv("FZF_DEFAULT_OPTS")
if not default_opts then return end
local patterns = { "--preview-window" }
for _, p in ipairs(patterns) do
-- remove flag end of string
default_opts = default_opts:gsub(utils.lua_regex_escape(p) .. "[=%s]+[^%-]+%s-$", "")
-- remove flag start/mid of string
default_opts = default_opts:gsub(utils.lua_regex_escape(p) .. "[=%s]+.+%s+%-%-", " --")
end
return default_opts
end)()
},
on_exit = function(_, rc, _)
local output = {}
Expand Down

0 comments on commit 348cb6b

Please sign in to comment.