linrongbin16 / fzfx.nvim

A Neovim fuzzy finder that updates on every keystroke.
https://linrongbin16.github.io/fzfx.nvim/
MIT License
122 stars 5 forks source link

Back action in `FzfxFileExplorer` does not work if directory is empty #507

Closed savchenko closed 8 months ago

savchenko commented 9 months ago

Steps to reproduce:

  1. cd into subdirectory that is empty
  2. Press "go up" hotkey
  3. Nothing happens

Is not affected by the https://github.com/linrongbin16/fzfx.nvim/issues/506 change.

linrongbin16 commented 8 months ago

thanks for your report! it's really an edge case that I didn't notice.

after debugging for several hours, I still didn't find the root cause.

but I guess if there's an exception failure, because there's an assert failed in the interaction rpc callback, then the whole plugin popup is lost. e.g. whatever the keys I press, there's no logging or other things.

linrongbin16 commented 8 months ago

After add more logging and debug again, I found the interaction RPC call actually doesn't send to nvim server at all.

That could relate to fzf's behavior, e.g. the binded key 'ctrl-h' is not working when there're no lines in left side. But this will need a re-produce example to approve the idea.

savchenko commented 8 months ago

That could relate to fzf's behavior, e.g. the binded key 'ctrl-h' is not working

For what it's worth, fzf --bind=ctrl-h:accept works just fine.

linrongbin16 commented 8 months ago

That could relate to fzf's behavior, e.g. the binded key 'ctrl-h' is not working

For what it's worth, fzf --bind=ctrl-h:accept works just fine.

no, after doing more debugging and investigation, I'm pretty sure that, when there's no lines in left side of fzf, then press 'CTRL-H', the callback functions are not been invoked.

The details of the press 'CTRL-H' to upper is:

  1. fzf is binding with --bind=ctrl-h:execute-silent(...)
  2. inside the execute-silent, the real shell command is: nvim -l -u NONE .../bin/rpc/request.lua <rpc-id> {}
  3. The last parameter {} is the placeholder, fzf will pass the current selected line to the .../bin/rpc/request.lua as shell argument.

With debug logging, I'm pretty sure that, for empty directory, since there're no lines in fzf left side, so fzf doesn't actually run the nvim -l -u NONE .../bin/rpc/request.lua command, so no interactions are sending to nvim backend, so no callbacks are been called.

There are 2 ways to make it work:

  1. When press 'ctrl-l' to cd into, detect if the directory is empty, and disallow user to cd into it.
  2. Keep current behavior, just press 'ctrl-u' to show hidden . and .., and user can go upper again.

I personally perfer the 2nd method, because disallow user to cd into a directory seems rude to me.

I will update the readme document and and a section 'Known Issues' to record this.

savchenko commented 8 months ago

Keep current behavior, just press 'ctrl-u' to show hidden . and .., and user can go upper again.

Very reasonable workaround!

linrongbin16 commented 8 months ago

Please see: https://linrongbin16.github.io/fzfx.nvim/#/KnownIssues