sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
14.95k stars 337 forks source link

Increase scrolling speed for preview-plugins #1554

Closed AnirudhG07 closed 1 month ago

AnirudhG07 commented 1 month ago

What system are you running Yazi on?

macOS

What terminal are you running Yazi in?

item

yazi --debug output

Yazi
    Version: 0.3.1 (cd7209c 2024-08-26)
    Debug  : false
    OS     : macos-aarch64 (unix)

Ya
    Version: 0.3.1 (cd7209c 2024-08-26)

Emulator
    Emulator.via_env: ("xterm-256color", "iTerm.app")
    Emulator.via_csi: Ok(Iterm2)
    Emulator.detect : Iterm2

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: None
    WAYLAND_DISPLAY : None
    DISPLAY         : None

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bin/zsh")
    EDITOR             : Some("nvim")
    VISUAL             : Some("nvim")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : Some("/Users/anirudhgupta/dotfiles/yazi/.config/yazi")

Text Opener
    default: Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : 3.4
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.41
    ueberzugpp       : 2.9.2
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-36
    fzf              : 0.54.3
    fd               : 10.1.0
    rg               : 14.1.0
    chafa            : 1.14.2
    zoxide           : 0.9.4
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.6

--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "/Users/anirudhgupta/.local/state/yazi" directory.

Did you try the latest nightly build to see if the problem got fixed?

Yes, and I updated the debug information above (yazi --debug) to the nightly that I tried

Describe the bug

The regular code scrolling is fast. I like it. But when it comes to scrolling Jupyter notebooks, it is really slow WHEN I use plugins like rich-preview or nbpreview. I know this is not an inbuilt feature for providing formatted and good looks for ipynb files. But it would be nice if there was a way we could increase the scrolling speed for these. Do you have any ideas for it?

Minimal reproducer

1) Download either of those plugins with ya pack -a AnirudG07/nbpreview or AnirudhG07/rich-preview 2) make a long Jupyter nb, and preview it.

You will see nbpreview takes more time to load compared to rich-preview. But after loaded, then slowness of scrolling is really bad. It practically makes viewing the notebooks useless. On the other hand, these provides inbuilt wrapping so we dont have to worry about that part.

Anything else?

No response

AnirudhG07 commented 1 month ago

Ok one thing I noticed, this is not just for notebooks. Any plugin based preview, the same issue will occur. Like if I display codes with bat the scrolling becomes SLOW. miller.yazi, glow.yazi, all are much slower.

sxyazi commented 1 month ago

First off, it's definitely not that the plugin itself is slow. All of Yazi's previewers are implemented through plugins (see them at https://github.com/sxyazi/yazi/tree/main/yazi-plugin/preset/plugins), and they run concurrently, plus, Lua is a very simple and fast language, so there's no reason for it to be slow.

On the other hand, the reason the built-in syntax highlighting is fast is that it calls Yazi's internal functions rather than external commands, which avoids the whole process creation lifecycle. Additionally, it's heavily optimized and is much faster than bat - bat renders the entire file instead of just the visible area. That's also why I chose to implement it myself, as I explained in https://github.com/sxyazi/yazi/issues/143.

To sum up, the speed of external previewers completely depends on how fast the external command is created and executed. This isn't something Yazi can fix. When it comes to process creation, you might need to tweak some OS-related settings. For execution, you'll need to find faster commands or implement a faster previewer yourself. I don't think these two aspects are issues Yazi can solve, because they're not really problems with Yazi itself.

AnirudhG07 commented 1 month ago

I understand. Thanks for the clarification. I was hoping to use bat, for the line numbers, having wrapping with line numbers would be a bit more comfortable.

github-actions[bot] commented 1 hour ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.