Skip to content

fix: reload before unhide buffers/tabs pickers #1871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/fzf-lua/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ M.CTX = function(opts)
-- perhaps a min impact optimization but since only
-- buffers/tabs use these we only include the current
-- list of buffers when requested
if opts.includeBuflist and not M.__CTX.buflist then
if opts.force or opts.includeBuflist and not M.__CTX.buflist then
-- also add a map for faster lookups than `utils.tbl_contains`
-- TODO: is it really faster since we must use string keys?
M.__CTX.bufmap = {}
Expand Down
26 changes: 16 additions & 10 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -601,29 +601,35 @@ M.defaults.buffers = {
_actions = function()
return M.globals.actions.buffers or M.globals.actions.files
end,
actions = { ["ctrl-x"] = { fn = actions.buf_del, reload = true } },
actions = {
["ctrl-x"] = { fn = actions.buf_del, reload = true },
["f11"] = { fn = actions.dummy_abort, reload = true },
},
_reload_bind = "<F11>",
_cached_hls = { "buf_nr", "buf_flag_cur", "buf_flag_alt", "path_linenr" },
}

M.defaults.tabs = {
previewer = M._default_previewer_fn,
tab_title = "Tab",
tab_marker = "<<",
file_icons = 1,
color_icons = true,
_actions = function()
previewer = M._default_previewer_fn,
tab_title = "Tab",
tab_marker = "<<",
file_icons = 1,
color_icons = true,
_actions = function()
return M.globals.actions.buffers or M.globals.actions.files
end,
actions = {
actions = {
["enter"] = actions.buf_switch,
["ctrl-x"] = { fn = actions.buf_del, reload = true },
["f11"] = { fn = actions.dummy_abort, reload = true },
},
fzf_opts = {
_reload_bind = "<F11>",
fzf_opts = {
["--multi"] = true,
["--delimiter"] = "[\\):]",
["--with-nth"] = "5..",
},
_cached_hls = { "buf_nr", "buf_flag_cur", "buf_flag_alt", "tab_title", "tab_marker", "path_linenr" },
_cached_hls = { "buf_nr", "buf_flag_cur", "buf_flag_alt", "tab_title", "tab_marker", "path_linenr" },
}

M.defaults.lines = {
Expand Down
4 changes: 2 additions & 2 deletions lua/fzf-lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ function M.fzf_winobj()
return loadstring("return require'fzf-lua'.win.__SELF()")()
end

function M.CTX()
return loadstring("return require'fzf-lua'.core.CTX()")()
function M.CTX(...)
return loadstring("return require'fzf-lua'.core.CTX(...)")(...)
end

function M.__CTX()
Expand Down
6 changes: 5 additions & 1 deletion lua/fzf-lua/win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,11 @@ end
function FzfWin.unhide()
local self = _self
if not self or not self:hidden() then return end
self._o.__CTX = utils.CTX()
self._o.__CTX = utils.CTX({ force = true })
-- reload list for buffers/tabs
if self._o._reload_bind then
utils.feed_keys_termcodes(self._o._reload_bind)
end
vim.bo[self._hidden_fzf_bufnr].bufhidden = "wipe"
self.fzf_bufnr = self._hidden_fzf_bufnr
self._hidden_fzf_bufnr = nil
Expand Down