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

iterm2 image preview in tmux sometimes has wrong position #1064

Closed
tianze0926 opened this issue May 20, 2024 · 7 comments · Fixed by #1070
Closed

iterm2 image preview in tmux sometimes has wrong position #1064

tianze0926 opened this issue May 20, 2024 · 7 comments · Fixed by #1070
Labels
bug Something isn't working

Comments

@tianze0926
Copy link

tianze0926 commented May 20, 2024

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

wezterm 20240203-110809-5046fc22

Did you try the latest code to see if this problem got fixed?

Tried, but the problem still

yazi --debug output

Yazi
    Version: 0.2.5 (bf1c325 2024-05-20)
    OS: linux-x86_64 (unix)
    Debug: true

Ya
    Version: Ok(Output { status: ExitStatus(unix_wait_status(0)), stdout: "ya 0.2.5\n", stderr: "" })

Emulator
    Emulator.via_env: ("tmux-256color", "tmux")
    Emulator.via_csi: Ok(WezTerm)
    Emulator.detect: WezTerm

Adaptor
    Adaptor.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: None
    WAYLAND_DISPLAY: None
    DISPLAY: None

SSH
    shared.in_ssh_connection: true

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

Variables
    SHELL: Some("/home/leo/.local/bin/fish")
    EDITOR: None
    ZELLIJ_SESSION_NAME: None
    YAZI_FILE_ONE: None
    YAZI_CONFIG_HOME: None

file(1)
    Version: Ok(Output { status: ExitStatus(unix_wait_status(0)), stdout: "file-5.38\nmagic file from /home/leo/miniconda3/envs/build/share/misc/magic\n", stderr: "" })

Text Opener
    default: None
    block: None

tmux
    TMUX: true

Ueberzug++
    Version: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" })

Describe the bug

In tmux when previewing images, some have wrong positions (at the bottom right corner):

image

Expected Behavior

Positions should be correct.

To Reproduce

Configuration

no config

Anything else?

I’ve noticed that smaller images tend to cause the issue, whereas normal-sized images haven’t caused any problems.

Possible fix

Interestingly, I found that making the following change as in #[cfg(windows)] can help mitigate the issue, although I’m not sure why.

diff --git a/yazi-shared/src/term/cursor.rs b/yazi-shared/src/term/cursor.rs
index 4cbbd0f..1a46b3f 100644
--- a/yazi-shared/src/term/cursor.rs
+++ b/yazi-shared/src/term/cursor.rs
@@ -36,6 +36,11 @@ impl Term {
                #[cfg(unix)]
                {
                        queue!(buf, SavePosition, MoveTo(x, y))?;
+
+                       use std::{thread, time::Duration};
+                       buf.flush()?;
+                       thread::sleep(Duration::from_millis(1));
+
                        let result = cb(&mut buf);
                        queue!(buf, RestorePosition)?;
                        buf.flush()?;
@tianze0926 tianze0926 added the bug Something isn't working label May 20, 2024
@sxyazi
Copy link
Owner

sxyazi commented May 21, 2024

I can't reproduce it.

screenshot-000047.mp4

What's your tmux version? Is it the latest one? Can you try using the default configurations for both tmux and WezTerm and set https://yazi-rs.github.io/docs/image-preview#tmux to see if the issue still?

Here’s my tmux version:

tmux -V
tmux 3.4

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label May 21, 2024
@tianze0926
Copy link
Author

The issue remains on the two systems I've tried:

  • NixOS unstable, Hyprland master branch
  • Arch Linux latest, KDE 6.0.4

Yazi is built from the main branch and has no config.

tmux version is 3.4 and the configuration only contains https://yazi-rs.github.io/docs/image-preview#tmux.

WezTerm has no config.

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label May 21, 2024
@sxyazi
Copy link
Owner

sxyazi commented May 21, 2024

Can you record a GIF to show me your steps? Also does it only happen with the specific combination of tmux and wezterm? Does this issue occur in other situations as well?

@tianze0926
Copy link
Author

untitled.webm

Without tmux everything works fine. As for other terminals that support iterm2, VS Code is nearly unusable in combination with tmux:

image

@sxyazi
Copy link
Owner

sxyazi commented May 21, 2024

Please try #1070

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label May 21, 2024
@tianze0926
Copy link
Author

Yes that works! Thanks for your help~

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label May 22, 2024
@sxyazi
Copy link
Owner

sxyazi commented May 22, 2024

Alright lemme merge then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants