Skip to content

Commit aeff813

Browse files
committed
fix(hide): reload buffer list pickers on unhide
Closes #1871 Closes #1896
1 parent 54005a6 commit aeff813

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lua/fzf-lua/profiles/hide.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local uv = vim.uv or vim.loop
22
local fzf = require("fzf-lua")
3+
local shell = require "fzf-lua.shell"
34
return {
45
desc = "hide interface instead of abort",
56
keymap = {
@@ -82,6 +83,15 @@ return {
8283
end
8384
return act
8485
end, opts.actions)
86+
-- Hijack the resize event to reload buffer/tab list on unhide
87+
opts.keymap.fzf.resize = "transform:" .. shell.raw_action(function(_, _, _)
88+
if opts._unhide_called then
89+
opts._unhide_called = nil
90+
if opts.__reload_cmd then
91+
return string.format("reload:%s", opts.__reload_cmd)
92+
end
93+
end
94+
end, "{q}", opts.debug)
8595
return opts
8696
end,
8797
},

lua/fzf-lua/utils.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,8 @@ function M.fzf_winobj()
797797
return loadstring("return require'fzf-lua'.win.__SELF()")()
798798
end
799799

800-
function M.CTX()
801-
return loadstring("return require'fzf-lua'.core.CTX()")()
800+
function M.CTX(...)
801+
return loadstring("return require'fzf-lua'.core.CTX(...)")(...)
802802
end
803803

804804
function M.__CTX()

lua/fzf-lua/win.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local path = require "fzf-lua.path"
22
local utils = require "fzf-lua.utils"
3+
local libuv = require "fzf-lua.libuv"
34
local config = require "fzf-lua.config"
45
local actions = require "fzf-lua.actions"
56

@@ -1211,7 +1212,12 @@ end
12111212
function FzfWin.unhide()
12121213
local self = _self
12131214
if not self or not self:hidden() then return end
1214-
self._o.__CTX = utils.CTX()
1215+
self._o.__CTX = utils.CTX({ includeBuflist = true })
1216+
self._o._unhide_called = true
1217+
-- Send SIGWINCH to to trigger resize in the fzf process
1218+
-- We will use the trigger to reload necessary buffer lists
1219+
local pid = fn.jobpid(vim.bo[self._hidden_fzf_bufnr].channel)
1220+
vim.tbl_map(function(_pid) libuv.process_kill(_pid, 28) end, vim._os_proc_children(pid))
12151221
vim.bo[self._hidden_fzf_bufnr].bufhidden = "wipe"
12161222
self.fzf_bufnr = self._hidden_fzf_bufnr
12171223
self._hidden_fzf_bufnr = nil

0 commit comments

Comments
 (0)