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

Ctrl-z sometimes break yazi #1309

Open ricardoseriani opened 1 month ago

ricardoseriani commented 1 month ago

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

wezterm 20240203-110809-5046fc22

yazi --debug output

```sh Yazi Version: 0.2.5 (VERGEN_IDEMPOTENT_OUTPUT 2024-04-23) OS: linux-x86_64 (unix) Debug: false Emulator Emulator.via_env: ("xterm-256color", "WezTerm") Emulator.via_csi: Ok(WezTerm) Emulator.detect: WezTerm Adaptor Adaptor.matches: Iterm2 Desktop XDG_SESSION_TYPE: Some("tty") WAYLAND_DISPLAY: None DISPLAY: Some(":0") SSH shared.in_ssh_connection: false WSL /proc/sys/fs/binfmt_misc/WSLInterop: false Variables SHELL: Some("/usr/bin/zsh") EDITOR: Some("vim") 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.41\nmagic file from /etc/magic:/usr/share/misc/magic\n", stderr: "" }) 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 Ueberzug++ Version: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" }) -------------------------------------------------- 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/rseriani/.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 I press ctrl-z to suspend yazi and then run fg to bring it back to foreground, the window is "freeze/broken". This sometimes occurs, but not always, so you may need a few tries to reproduce.

Expected Behavior

Yazi should be working when it's back to foreground.

To Reproduce

run yazi press ctrl-z run fg to bring it back to foreground try using yazi normally

Configuration

no config

Anything else?

2024-07-18_10-13

sxyazi commented 1 month ago

I made some fixes to the behavior of Ctrl-Z earlier in https://github.com/sxyazi/yazi/pull/1307, please give it a try

ricardoseriani commented 1 month ago

I tried applying the PR locally, but I'm not really sure if this is the correct way:

Apparently, the PR was applied.

If what I was made is correct, unfortunately, the problem still persists.

sxyazi commented 1 month ago

What does the yazi --debug output look like? Does it include the hash of that commit? Can you record a gif so I can see your steps and what happens?

ricardoseriani commented 1 month ago

yazi --debug output

```sh Yazi Version: 0.2.5 (d88211c 2024-07-18) Debug : false OS : linux-x86_64 (unix) Ya Version: 0.2.5 Emulator Emulator.via_env: ("xterm-256color", "WezTerm") Emulator.via_csi: Ok(WezTerm) Emulator.detect : WezTerm Adapter Adapter.matches: Iterm2 Desktop XDG_SESSION_TYPE: Some("tty") WAYLAND_DISPLAY : None DISPLAY : Some(":0") SSH shared.in_ssh_connection: false WSL /proc/sys/fs/binfmt_misc/WSLInterop: false Variables SHELL : Some("/usr/bin/zsh") EDITOR : Some("vim") ZELLIJ_SESSION_NAME: None YAZI_FILE_ONE : None YAZI_CONFIG_HOME : 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: tmux 3.2a Dependencies file : 5.41 ueberzugpp : No such file or directory (os error 2) ffmpegthumbnailer: No such file or directory (os error 2) magick : No such file or directory (os error 2) fzf : 0.54.0 fd : 10.1.0 rg : 14.1.0 chafa : zoxide : No such file or directory (os error 2) unar : 1.10.1 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/rseriani/.local/state/yazi" directory. ```

Video record of the problem

https://github.com/user-attachments/assets/307cd69d-b780-4d90-a69c-c4c1ded71b21

sxyazi commented 1 month ago

Hi, I made a new PR, please try https://github.com/sxyazi/yazi/pull/1310

ricardoseriani commented 1 month ago

I tried it, and the problem still persists. But now, when this occurs, I can press ctrl-z to stop yazi and then send it back to foreground with fg and it's back working again.

sxyazi commented 1 month ago

That's so weird, with https://github.com/sxyazi/yazi/pull/1310/commits/fa297b31c04ee1c1b2f26b3b4ebca8d4b533899e, I can't reproduce it on my Linux VM anymore, no matter how many times I try, it works fine for me.

https://github.com/user-attachments/assets/b7ad3d9d-426f-4f73-b13b-9a7a1ed27f13

Are you sure you're using that commit right? Did I miss any details to reproduce it?

ricardoseriani commented 1 month ago

I tried again and recorded this time.

https://github.com/user-attachments/assets/cec276a8-1e38-4799-8676-2d41f1921c25

I tried with xfce4-terminal (xfce4-terminal 0.8.10 (Xfce 4.16)) and the problem occurs in it too.

I known it's hard to make sure that it's fixed, because it's not always reproducible.

sxyazi commented 1 month ago

Please apply these two patches separately on top of that PR and see what happens:

--- yazi/yazi-fm/src/app/commands/resume.rs
+++ yazi/yazi-fm/src/app/commands/resume_new.rs
@@ -4,7 +4,6 @@

 impl App {
    pub(crate) fn resume(&mut self, _: Cmd) {
-       self.cx.manager.active_mut().preview.reset_image();
        self.term = Some(Term::start().unwrap());

        // While the app resumes, it's possible that the terminal size has changed.
--- yazi/yazi-fm/src/app/commands/resume.rs
+++ yazi/yazi-fm/src/app/commands/resume_new.rs
@@ -4,13 +4,12 @@

 impl App {
    pub(crate) fn resume(&mut self, _: Cmd) {
-       self.cx.manager.active_mut().preview.reset_image();
+       self.signals.resume(None);
+
        self.term = Some(Term::start().unwrap());

        // While the app resumes, it's possible that the terminal size has changed.
        // We need to trigger a resize, and render the UI based on the resized area.
        self.resize(());
-
-       self.signals.resume(None);
    }
 }
ricardoseriani commented 1 month ago

I tried both separately, but it still doesn't work.

sxyazi commented 1 month ago

I have no idea then. After applying that PR, the issue completely disappeared for me, and before applying that PR, I could reproduce it with the Linux + WezTerm combo (it couldn't be reproduced on non-Linux systems or without WezTerm).

I'll keep it open for a while to see if anyone else encounters it and can provide more clues and help debug it.