ibhagwan / fzf-lua

Improved fzf.vim written in lua
MIT License
2.29k stars 149 forks source link

Pasting text freezes FzfLua when using builtin previewer #909

Closed tobiwild closed 10 months ago

tobiwild commented 1 year ago

Info

Description

Reproduce:

I checked with git bisect and found that 32821ea80674c053d3c407034625925cb20dd101 introduced this behaviour, and indeed when I change the previewer for files to bat the issue is gone.

ibhagwan commented 1 year ago

Ty for the report @tobiwild, I’ll look into it.

ibhagwan commented 1 year ago

@tobiwild, I can't seem to reproduce this, can you share some more pointers when this happens exactly?

ibhagwan commented 1 year ago

Can you also try to download fzf v0.39 binary and try the same with:

:lua require("fzf-lua").files({ fzf_bin = "/path/to/fzf-v0.39" })
tobiwild commented 12 months ago

I checked again and found that the FZF zero event and the shell execution seems to be the issue, disabling this zero event helps. I tested also with disabling the clear_preview_buf call:

diff --git a/lua/fzf-lua/previewer/builtin.lua b/lua/fzf-lua/previewer/builtin.lua
index 9a4f558..f901db9 100644
--- a/lua/fzf-lua/previewer/builtin.lua
+++ b/lua/fzf-lua/previewer/builtin.lua
@@ -292,11 +292,14 @@ function Previewer.base:cmdline(_)
   return act
 end

+local calls = 0
 function Previewer.base:zero(_)
   local act = string.format("execute-silent(%s)",
     shell.raw_action(function(_, _, _)
-      self:clear_preview_buf(true)
-      self.last_entry = nil
+      calls = calls + 1
+      vim.notify("Previewer Zero Call " .. calls)
+      -- self:clear_preview_buf(true)
+      -- self.last_entry = nil
     end, "", self.opts.debug))
   return act
 end

The issue remains:

https://github.com/ibhagwan/fzf-lua/assets/891533/5986bcd1-ba01-4ccc-9e60-15415e1f6c26

Typing the string fast works fine, pasting via <C-\><C-n>p has the same issue.

But I now switched to bat which I'm also fine with.

ibhagwan commented 12 months ago

I checked again and found that the FZF zero event

The zero even is used to clear the previewer when fuzzy matching yields no results, it was only introduced since fzf 0.40 that’s why I asked to try with 0.39 as I suspected this might be it based on the commit you linked.

I tested also with disabling the clear_preview_buf call:

from the video it seems your notification is being called and you can exit fzf-lua, what do you exactly mean by fzf-lua freezes”?

After analyzing your screencast this seems to be working as expected, typing Previewer simply yields no results (note the 0/63 in the info line I.e. no matches), can you try slowly deleting characters with backspace and see when you start getting results again?

ibhagwan commented 11 months ago

Losing due to inactivity, feel free to reopen if this is still an issue @tobiwild.

somnam commented 11 months ago

I'm having the same issue when pasting in files search:

Here's an example of pasting fzf_lua_history string having no results:

@ibhagwan Would it be possible to look into this issue? I'll try switching to a different previewer than the bulitin and see if this helps.

ibhagwan commented 11 months ago

Can you also try to download fzf v0.39 binary and try the same with:

:lua require("fzf-lua").files({ fzf_bin = "/path/to/fzf-v0.39" })

@somnam, what is your fzf version? are you also on MacOS? Can you try with fzf version 0.39 as mentioned above and let me know if the issues exists with 0.39?

somnam commented 11 months ago

@somnam, what is your fzf version? are you also on MacOS? Can you try with fzf version 0.39 as mentioned above and let me know if the issues exists with 0.39?

Yep, I'm on MacOS too, but using bash & wezterm. I was using the latest fzf version 0.44.1 installed from git repo with --bin option. After switching back to 0.39 it looks like the issue has gone away. The problem seems to be linked with the zero event (0.40.0 has the same problem for me). Is there some additional info / debug I could provide?

ibhagwan commented 11 months ago

@somnam, what is your fzf version? are you also on MacOS? Can you try with fzf version 0.39 as mentioned above and let me know if the issues exists with 0.39?

Yep, I'm on MacOS too, but using bash & wezterm. I was using the latest fzf version 0.44.1 installed from git repo with --bin option. After switching back to 0.39 it looks like the issue has gone away. The problem seems to be linked with the zero event (0.40.0 has the same problem for me). Is there some additional info / debug I could provide?

No need to provide any additional info, I was able to reproduce this, not sure what causes the freeze yet but it seams to stem from consecutive calls to the zero event, I have an idea to solve this with a singleton shell command, I’ll test it tomorrow.

ibhagwan commented 11 months ago

@tobiwild, @somnam, turns out this is an issue with fzf, opened an issue upstream: https://github.com/junegunn/fzf/issues/3516

Edit: https://github.com/ibhagwan/fzf-lua/commit/1fa0252f760cec028709e02f7473a5156d1ad040 - added debounce mechanism to the zero event in hope this will alleviate the issue a bit, we'll still have to wait for the upstream for a proper fix.

ibhagwan commented 10 months ago

FYI, this is solved at the upstrem's HEAD, waiting for a new release to close this issue.

ibhagwan commented 10 months ago

Closing this with the release of fzf v0.45