-
Notifications
You must be signed in to change notification settings - Fork 197
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
Conversation
* also fix a regression after unhide a buffer, actions cause an error since ctx updated
Interesting, I don’t see the connection to the changes in the commit to reload actions. Tysm @phanen for yet another PR :) Can’t say I’m super excited about this as it feels a bit “hacky” having a dummy reload bind, I’m trying to think is there another approach to this with an fzf event? Maybe a |
Btw, there is a better solution but it requires a big refactor and also to drop support for skim, I’ve been thinking for a while of using a With listen we can post a “reload” request anytime over the HTTP socket not needing a bind . |
@phanen, checkout main...pr_1871, I still wasn't able to make it work but I feel this is the right direction, I'm trying to hijack the resize event and then using a variable as I mentioned at the previous comments to perform a "oneshot" reload. The resize however doesn't trigger on unhide so I've been trying to trigger a resize with SIGWINCH (signal 28) but it seems to do nothing when sent to fzf (even with I will attempt to solve this later. |
Sorry not
Yes, with this would be easier as just
It work for me? At least it print |
Maybe it’s not that critical but I hate to rely on additional binaries being is installed, that’s why I prefer a native lua HTTP post library but luasocket is yet another requirement so I’m also not loving it. Windows not having sig 28 I can live with, windows already has loads of limitations and doesn’t really work well with hide, for example I’m still not sure why sit 28 doesn’t work with fzf on my Linux, to be explored.
Interesting we had the same thought :)
My idea was an Fzf class/object, each new instance with their own listen address (+ auth token so “safe”) so we’re not limited to one fzf process, that the user can instantiate and attach to any window, that way you could run say A few concerns with the new approach:
On the plus side this will simplify the code significantly and we can create a proper API and code structure from scratch as opposed to the sometimes not so organized building blocks we currently have due to fzf-lua being developed for a long time incrementally, definitely doesn’t help that I’m also busy in life and other interesting projects so have to find the right motivation for such a big rewrite. |
Recently I found a http lib based on neovim bundled libuv: https://github.com/sfenzke/http-client.nvim.git
I found there're still many limitations even if use HTTP API, since many flags are one-way-door (behavior like
Forgot about this. Just open a issue to track: skim-rs/skim#719
Yes, I'm comfortable with current fzf-lua's performance/rich-feature. |
I feared the HTTP API isn’t there yet to accommodate all the features we need.
Combining actions/keymap.fzf/keymap.builtin into one table with neovim style binds is also something that was on my mind for a while, it’s even possible with the current architecture just a tiny bit more complicated to design, but then again there needs to be proper motivation as the onky benefit for this is nicer/simpler configuration. |
@ibhagwan I checkout your SIGWINCH commit again know why it didn't work: Patch on your commit that work: diff --git a/lua/fzf-lua/profiles/hide.lua b/lua/fzf-lua/profiles/hide.lua
index acb7f9c..4187370 100644
--- a/lua/fzf-lua/profiles/hide.lua
+++ b/lua/fzf-lua/profiles/hide.lua
@@ -82,10 +82,11 @@ return {
end
return act
end, opts.actions)
- -- Hijack the resize event to reload buffer/tab list on unhide
- opts.keymap.fzf.resize = function()
- print("resize called", opts._oneshot_fzf)
- end
+ opts.actions.resize = { fn = fzf.actions.dummy_abort, reload = true }
+ -- -- Hijack the resize event to reload buffer/tab list on unhide
+ -- opts.keymap.fzf.resize = function()
+ -- print("resize called", opts._oneshot_fzf)
+ -- end
return opts
end,
},
diff --git a/lua/fzf-lua/win.lua b/lua/fzf-lua/win.lua
index 0c1828d..7a1d285 100644
--- a/lua/fzf-lua/win.lua
+++ b/lua/fzf-lua/win.lua
@@ -1217,7 +1217,8 @@ function FzfWin.unhide()
-- Send SIGWINCH to to trigger resize in the fzf process
-- We will use the trigger to reload necessary buffer lists
local pid = fn.jobpid(vim.bo[self._hidden_fzf_bufnr].channel)
- libuv.process_kill(pid, 28)
+ -- libuv.process_kill(pid, 28)
+ vim.tbl_map(function(_pid) libuv.process_kill(_pid, 28) end, vim._os_proc_children(pid))
vim.bo[self._hidden_fzf_bufnr].bufhidden = "wipe"
self.fzf_bufnr = self._hidden_fzf_bufnr
self._hidden_fzf_bufnr = nil |
Nice @phanen! I still haven’t gotten to it as I’m busy with a new open source project I will soon(ish) publish :) Do you find the SIGWINCH approach cleaner? |
At least better than feeding termcodes...? |
I agree. |
Related: #1901 (reply in thread). |
Since I bind my `ctrl-l` to other actions rather than `clear-screen` so I spot this upsteram bug again kevinhwang91@bdc2a4e. `resize` can trigger `clear-screen` in fzf. So this might be a better way to force `redraw` in linux. Related: * ibhagwan/fzf-lua#1871 * ibhagwan/fzf-lua#1901 (reply in thread) > * By `resize` there's false positive: e.g. windows manager users may often resize window manualy > * And I'm not sure `SIGWINCH` and fzf's `resize` work correctly on Windows. > * By `chan_send`/`feedkeys` we override user's key bindings (although there's already some `chan_send` hacks in codebase like: toggling preview (this is handled better by scanning user's fzf bindings config... but will be weird if user set bindings from `FZF_DEFAULT_OPTS`), mirroring the `esc` to fzf (this is opt-in by a hide profile).
@phanen, will you look at my latest PR branch commit main...pr_1871 and let me know what you think? Instead of unconditionally calling reload on every resize (fake or not) I modified the resize event to a transform that only calls the reload once upon our "fake" resize and only does so with pickers that have The only thing I'm not sure is if I want to add a var to enable the "hide-reload" only for specific pickers or do so for all pickers that have |
IMO that's enough since those buffer is not performance critical? I'm not those using thousand of buffers but I test But there seems a bug (racing?) after I open
Here: the second fzf-lua/lua/fzf-lua/providers/buffers.lua Line 187 in ee80318
|
After
da9a089480e29cActions like
ctrl-x
may throw an error since CTX updated.This PR
buflist
for buffers