@@ -36,26 +36,40 @@ T["win"]["hide"]["ensure gc called after win hidden (#1782)"] = function()
3636 return setmetatable(t, mt)
3737 end
3838 ]] )
39- child .wait_until (function ()
40- if helpers .IS_WIN () then
41- local hidden_fzf_bufnr = child .lua_get (
42- [[ (FzfLua.utils.fzf_winobj() or {})._hidden_fzf_bufnr]] )
43- if hidden_fzf_bufnr ~= vim .NIL then
44- local chan = child .lua_get (([=[ vim.bo[%s].channel]=] ):format (hidden_fzf_bufnr ))
45- child .api .nvim_chan_send (chan , vim .keycode (" <c-c>" ))
46- end
39+ if helpers .IS_WIN () then
40+ local hidden_fzf_bufnr = child .lua_get (
41+ [[ (FzfLua.utils.fzf_winobj() or {})._hidden_fzf_bufnr]] )
42+ if hidden_fzf_bufnr ~= vim .NIL then
43+ local chan = child .lua_get (([=[ vim.bo[%s].channel]=] ):format (hidden_fzf_bufnr ))
44+ child .api .nvim_chan_send (chan , vim .keycode (" <c-c>" ))
4745 end
48- -- TODO: why isn't gc called with the builtin previewr
49- -- child.lua([[FzfLua.files{ previewer = 'builtin' }]])
50- child .lua ([[ FzfLua.files{ previewer = false }]] )
51- child .wait_until (function ()
52- return child .lua_get ([[ _G._fzf_load_called]] ) == true
53- end )
54- child .lua ([[ FzfLua.hide()]] )
55- child .wait_until (function ()
56- return child .lua_get ([[ _G._fzf_load_called]] ) == vim .NIL
57- end )
58- child .lua ([[ collectgarbage('collect')]] )
46+ end
47+ child .lua ([[ FzfLua.files{ previewer = 'builtin' }]] )
48+ -- child.lua([[FzfLua.files{ previewer = false }]])
49+ child .wait_until (function ()
50+ return child .lua_get ([[ _G._fzf_load_called]] ) == true
51+ end )
52+ child .lua ([[ FzfLua.hide()]] )
53+ child .wait_until (function ()
54+ return child .lua_get ([[ _G._fzf_load_called]] ) == vim .NIL
55+ end )
56+ -- Clear the function registry to unref all the stored opts
57+ -- and verify we're cleared by testing the id of a new func
58+ child .lua ([[ FzfLua.shell.clear_registry()]] )
59+ eq (child .lua_get ([[ FzfLua.shell.register_func(function() end)]] ), 1 )
60+ -- Open a new picker to unref the hidden window object, since
61+ -- we cleared the registry we need to re-setup the load event
62+ child .lua ([[ FzfLua.buffers{
63+ previewer = false,
64+ -- both keymap.fzf and actions work here
65+ -- keymap = { fzf = { load = function() _G._fzf_load_called = true end } }
66+ actions = { load = { fn = function() _G._fzf_load_called = true end, exec_silent = true } },
67+ }]] )
68+ child .wait_until (function ()
69+ return child .lua_get ([[ _G._fzf_load_called]] ) == true
70+ end )
71+ child .lua ([[ collectgarbage('collect')]] )
72+ child .wait_until (function ()
5973 return child .lua_get ([[ _G._gc_called]] ) == true
6074 end )
6175end
0 commit comments