diff --git a/lua/fzf-lua/actions.lua b/lua/fzf-lua/actions.lua index 95525519..1fb7bdba 100644 --- a/lua/fzf-lua/actions.lua +++ b/lua/fzf-lua/actions.lua @@ -57,8 +57,14 @@ M.normalize_selected = function(actions, selected, opts) -- and makes sure 'selected' contains only item(s) or {} -- so it can always be enumerated safely if not actions or not selected then return end - if opts.__FZF_VERSION and opts.__FZF_VERSION >= 0.53 then + if opts.__FZF_VERSION and opts.__FZF_VERSION >= 0.53 + or opts.__SK_VERSION and opts.__SK_VERSION >= 0.14 then -- Using the new `print` action keybind is expected at `selected[1]` + -- NOTE: if `--select-1|-q` was used we'll be missing the keybind + -- since `-1` triggers "accept" assume "enter" (#1589) + if selected and #selected == 1 then + table.insert(selected, 1, "enter") + end local entries = vim.deepcopy(selected) local keybind = table.remove(entries, 1) return keybind, entries diff --git a/lua/fzf-lua/fzf.lua b/lua/fzf-lua/fzf.lua index 47cbfd13..722d4091 100644 --- a/lua/fzf-lua/fzf.lua +++ b/lua/fzf-lua/fzf.lua @@ -248,7 +248,6 @@ function M.raw_fzf(contents, fzf_cli_args, opts) -- from FZF_DEFAULT_OPTS (#1107) local default_opts = os.getenv("FZF_DEFAULT_OPTS") if not default_opts then return end - local flags = { "--select-1", "-1" } local patterns = { "--preview-window" } for _, p in ipairs(patterns) do -- remove flag end of string @@ -256,6 +255,8 @@ function M.raw_fzf(contents, fzf_cli_args, opts) -- remove flag start/mid of string default_opts = default_opts:gsub(utils.lua_regex_escape(p) .. "[=%s]+.-%s+%-%-", " --") end + -- NOTE: better support for this via `actions.normalize_selected` + --[[ local flags = { "--select-1", "-1" } for _, p in ipairs(flags) do local escaped = utils.lua_regex_escape(p) repeat @@ -267,7 +268,7 @@ function M.raw_fzf(contents, fzf_cli_args, opts) default_opts = default_opts:gsub(string.format("%s%s%s", before, escaped, after), "") end until not has_opt - end + end ]] return default_opts end)(), -- Nullify user's RG config as this can cause conflicts