sxyazi / yazi

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

The cursor disappears in the preview panel when resizing yazi. #1458

Closed TobisLee closed 2 weeks ago

TobisLee commented 1 month ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

kitty 0.35.2

yazi --debug output

Yazi
    Version: 0.3.0 (4150f401 2024-08-09)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.0

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE: Some("wayland")
    WAYLAND_DISPLAY : Some("wayland-0")
    DISPLAY         : Some(":0")

SSH
    shared.in_ssh_connection: false

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

Variables
    SHELL              : Some("/usr/bin/fish")
    EDITOR             : Some("nvim")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None
    ZELLIJ_SESSION_NAME: None

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 })

tmux
    TMUX   : false
    Version: 3.4

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

--------------------------------------------------
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 "/home/tlss/.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

When the window size is reduced, the out-of-bounds cursor cannot be displayed in the preview pane.

Preview panel cursor shows in fullscreen. 屏幕截图_20240810_154511

Preview panel cursor disappears after resizing the window. 屏幕截图_20240810_154538

Minimal reproducer

  1. Open yazi in fullscreen.
  2. Enter the directory with a bunch of files.
  3. Go to the bottom of this directory.
  4. Resize the yazi window.

Anything else?

No response

sxyazi commented 1 month ago

Anyone wants to give it a go?

When the terminal size changes, the resize command is triggered:

https://github.com/sxyazi/yazi/blob/dac72eb39a846d15db7f1a7c54e9261675a90e53/yazi-fm/src/app/commands/resize.rs#L16

and this method calls self.current_or_mut(opt.tab).repos:

https://github.com/sxyazi/yazi/blob/dac72eb39a846d15db7f1a7c54e9261675a90e53/yazi-fm/src/app/commands/resize.rs#L21

https://github.com/sxyazi/yazi/blob/dac72eb39a846d15db7f1a7c54e9261675a90e53/yazi-core/src/manager/commands/hover.rs#L30

I think we can handle it there.

TobisLee commented 4 weeks ago

I noticed that the cursor disappears in both the preview and current panels when resizing the window.

Thanks for the hint. I checked the repos code, which should reposition the cursor, but it doesn't seem to fix the issue.

From what I understand, the cursor's position is correct after resizing, but the displayed content isn't. I noticed that the offset variable represents the starting position of the first file shown in the current panel within the entire file list. I managed to fix the cursor disappearing in the current panel by adjusting the offset value, but the issue persists in the preview panel.

sxyazi commented 4 weeks ago

We can start by only implementing the current panels.