Skip to content
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

feature: [explorer]Improve the performance of cursor jump #869

Closed
1 task done
xian-wen opened this issue Feb 2, 2025 · 93 comments · Fixed by #810
Closed
1 task done

feature: [explorer]Improve the performance of cursor jump #869

xian-wen opened this issue Feb 2, 2025 · 93 comments · Fixed by #810
Labels
enhancement New feature or request

Comments

@xian-wen
Copy link

xian-wen commented Feb 2, 2025

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

Hi, is it possible to improve the performance of the cursor jump in Snacks.explorer? Currently, it is a little bit sluggish, as you can see in the recording of the comparison between neo-tree and Snacks.explorer.
neo-tree:
Image
Snacks.explorer:
Image

Describe the solution you'd like

Just make the cursor jump a little bit more smoother.

Describe alternatives you've considered

Borrow the solution from neo-tree?

Additional context

No response

@xian-wen xian-wen added the enhancement New feature or request label Feb 2, 2025
@folke
Copy link
Owner

folke commented Feb 2, 2025

That's not normal. It seems to be the git status command that is slow on your machine for some reason. Any ideas?

@folke
Copy link
Owner

folke commented Feb 2, 2025

Disable git status to test

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Below is the time of git status, a little bit too long:
Image

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

So is it possible to not always run the git status command every time the keymap is triggered?

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

I will make a recording after disabling the git_status, which improves a lot, but still feels jumpy.

@folke
Copy link
Owner

folke commented Feb 2, 2025

That is extremely slow.
The same command for me runs in 5ms so 1000x faster than in your case.

What about the fd command?

There really must be something wrongly configured somewhere on your system.

I will however change it so that slow git commands don't prevent navigating the list.

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Hi, below is the recording with git_status = false:
Image

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

It is not slow, but a little bit jumpy?

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

That is extremely slow.
The same command for me runs in 5ms so 1000x faster than in your case.

This is just an academic docker environment, Ubuntu 22.04. I think there is no problem for fd since Snacks.picker runs fast.

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Below is the recording of Snacks.picker, at least it is better than telescope and not slower than fzf-lua:
Image

@folke
Copy link
Owner

folke commented Feb 2, 2025

I just changed it so that git status no longer blocks anything.
But that of course won't fix your 5s execution time. It will just make sure you will be able to use the explorer
without waiting till it finished.

Closing.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2025
@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

I find that neo-tree also displays the icons asynchronously when opening the first time, but when running the second, third, and so forth, time, the icons are displayed instantly. Maybe it uses some cache trick.

@folke
Copy link
Owner

folke commented Feb 2, 2025

you mean the git icons? So does the snacks picker. Did you update?

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Yes, I have updated to the latest version of Snacks. I mean the git icons displayed in Snacks.explorer each time just like they displayed in neo-tree the first time. When they displayed the following times in neo-tree, I cannot see any delays.

@folke
Copy link
Owner

folke commented Feb 2, 2025

ok, you probably mean the directory status symbols.

@folke
Copy link
Owner

folke commented Feb 2, 2025

Just changed that as well. You should no longer see the delays for git status.

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Below is the recording of the comparison between neo-tree and Snacks.explorer, pay attention to the icons:
neo-tree:
Image
Snacks.explorer:
Image
As we can see, neo-tree also takes some time to display the icons the first time, but later, it displays extremely fast. It must use some cache tricks I think.

@folke
Copy link
Owner

folke commented Feb 2, 2025

ok, now I understand what you mean.
I don't keep the git status cache in betwen opening the explorer. Will chaneg

@folke
Copy link
Owner

folke commented Feb 2, 2025

And I also had pushed a 1 second sleep for testing, which didn't help :)

@folke
Copy link
Owner

folke commented Feb 2, 2025

try again

@xian-wen
Copy link
Author

xian-wen commented Feb 2, 2025

Awesome! Thank you so much.
Image

@xian-wen
Copy link
Author

xian-wen commented Feb 3, 2025

Hi, folke, sorry to bother you once again. I just want Snacks.explorer to be better. Is it possible to improve the user experience when closing and opening a node? Currently, I could clearly see something like a refresh when closing and opening, which does not exist in neo-tree, as you can see in the recordings shown below:
neo-tree:
Image
Snacks.explorer:
Image

@folke folke reopened this Feb 3, 2025
@folke
Copy link
Owner

folke commented Feb 3, 2025

This is getting a bit annoying tbh. On my laptop there's literally no visible delay. Never has been before I started all these changes.

I can indeed change it, but seriously, just fix your computer...

@xian-wen
Copy link
Author

xian-wen commented Feb 3, 2025

Yeah, this is indeed annoying, sorry once again. This problem does not exist on my WSL. On WSL, everything feels smooth and fast. And I also cannot see any visible delay. It just happens on a docker environment, which might also be used by other people.
Snacks.explorer on WSL:
Image

@folke folke closed this as completed in cef4fc9 Feb 3, 2025
@folke
Copy link
Owner

folke commented Feb 4, 2025

Is there a hidden or ignored file in there?

@xian-wen
Copy link
Author

xian-wen commented Feb 4, 2025

Just one code directory, all others are dotfiles, which is shown when h is toggled on.
Image

@folke
Copy link
Owner

folke commented Feb 4, 2025

fixed

@xian-wen
Copy link
Author

xian-wen commented Feb 4, 2025

Looks pretty beautiful. Thank you so much. I think my dream file explorer has been born. I have been sitting in front of my computer and refreshing the Snacks repo every few minutes. I am so excited and appreciated for what you have done. Have a good night. On my timezone, it is 4:15 AM now.🤣

@folke
Copy link
Owner

folke commented Feb 4, 2025

Thank you and get some sleep! :)

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Hi, when watch is disabled, does this mean we can no longer track the file status? Since there is no git status icon when a file has been changed.
Image

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Also, when explorer is opened, the content in the window has been changed to the top view of the buffer. After closing, the content is back. As you can see in the above recording.

@folke
Copy link
Owner

folke commented Feb 5, 2025

When the file watcher is disabled, only buffer writes and lazygit terminal closes will result in a git refresh.
On linux, you can install inotify-tools. That will be used when available and doesn't have the associated issues like you experienced before.

I can't reproduce that issues when the explorer opened. But I'm also not sure I fully understand what you mean.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I mean before <Leader>e is pressed, the cursor is on Line 86, i.e., the visible range is [66, 96], while after the explorer is opened, the visible range in the right window is [1, 31], i.e., the first 31 lines are shown.

@folke
Copy link
Owner

folke commented Feb 5, 2025

Did you enable the main preview for explorer?

@folke
Copy link
Owner

folke commented Feb 5, 2025

Just tried with the minimal repro and also can't reproduce this there

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I think the problem comes from the preview, when I have

layout = { enabled = false, preview = "main" }

removed,
there is no such issue.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Sorry, my bad. The config should be:

            layout = {
              preview = {
                enabled = false,
                main = true,
              },
            },

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I just tested LazyVim in both WSL and docker, the problem still exists when toggle in "main" is set, and disappears when this is unset.
Image

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I find the problem, enabled = false seems does not work. When the explorer is opened, with the above config, preview is toggled on by default, so all files are in preview state, thus only the top view is shown. When I press P, the preview is toggled off, and the cursor line is back.

@folke
Copy link
Owner

folke commented Feb 5, 2025

fixed

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Awesome! Thank you so much.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

On linux, you can install inotify-tools. That will be used when available and doesn't have the associated issues like you experienced before.

I have inotify-tools installed, and inotifywait is executable, however, git signs are still not shown no matter how long I wait. I need to reopen neovim to see the git icons, :e! also does not work.
Image

@folke
Copy link
Owner

folke commented Feb 5, 2025

You no longer need inotity-tools.

I've changed the implementation since to no longer use NEovim's file watcher implementation,
since it's terrible for performance.

My new implementation works on all platforms, without any additional files needed.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I have uninstalled inotify-tools. There are still no git signs displayed when a file has changed.

@folke
Copy link
Owner

folke commented Feb 5, 2025

Can you check again?

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I just updated and tested with LazyVim, nothing has changed, on both WSL and docker.

@folke
Copy link
Owner

folke commented Feb 5, 2025

This is really annoying since I can't reproduce it.
IS there anything special about the directory or files you're doing this with?

Start with opening neovim from an actual project diretcory.
open a file from that project
see if it then works.

There's nothing for me to fix if I can't reproduce it.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

I just run lazyvim in .dofiles on WSL, then press f to find the file ./.config/lazyvim/config/options.lua, then add an option, no matter I updated the file or not, git status icons are not updated in explorer.
Image

@folke
Copy link
Owner

folke commented Feb 5, 2025

ok, I can reproduce it in the exact same way indeed.

@folke
Copy link
Owner

folke commented Feb 5, 2025

If you'd keep the explorer open it would update properly.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Yeah. Indeed. 🤣 But usually, we would like to code in the full-screen, as it is relatively small on a laptop.

@folke
Copy link
Owner

folke commented Feb 5, 2025

ok, check again.

@xian-wen
Copy link
Author

xian-wen commented Feb 5, 2025

Tested, OK! Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants