sxyazi / yazi

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

max_width / max_heigth only affects image preview but not pdf preview #1197

Closed Mirkopoj closed 1 week ago

Mirkopoj commented 1 week ago

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

Alacritty

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

Tried, but the problem still

yazi --debug output

```sh Yazi Version: 0.2.5 (Arch Linux 2024-06-23) Debug : false OS : linux-x86_64 (unix) Ya Version: 0.2.5 Emulator Emulator.via_env: ("alacritty", "") Emulator.via_csi: Ok(Unknown([])) Emulator.detect : Unknown([]) Adapter Adapter.matches: X11 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/fish") EDITOR : Some("nvim") 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: 3.4 Dependencies file : 5.45 ueberzugpp : 2.9.6 ffmpegthumbnailer: 2.2.2 magick : 7.1.1-33 fzf : 0.53.0 fd : 10.1.0 rg : 14.1.0 chafa : 1.14.1 zoxide : 0.9.4 unar : 1.10.7 jq : 1.7.1 ```

Describe the bug

I have 1 pdf file that breaks Ueberzug++ when max_width > 200, but for it to fit properly in yazi it needs have max_width = 95. So I edited mi yazi.toml and set max_width = 200, ran yazi --clear-cache and the error persited. After checking the Ueberzug log I found that the command was still using max_width = 330. I kept reducing max_width with no luck until I max_width =2 with no effect, then I realized that images where scalled down, but pdf preview wasn't. Using ueberzug scale fixes the issue, but I need to set a global 0.6 scalling when most content looked perfect before.

Expected Behavior

I would expect max_width to limit all previewed content's width, not just images.

To Reproduce

I guess the best I can do is to send the pdf that causes the problem.

Beginner's Guide To 3D Art Assets - Buildings.pdf

Configuration

no config

Anything else?

The pdf I attached is the main problem because it brakes Ueberzug, wich I understand isn't a concern here. But almost all pdfs are out of scale and look wrong on preview and the only solution that works is global scaling.

It would be nice to be able to set the maximum width so that it would make all previews fit the preview panel.

sxyazi commented 1 week ago

Please follow https://yazi-rs.github.io/docs/image-preview#debug-ueberzug to upload these logs

Mirkopoj commented 1 week ago

yazi log

  2024-06-24T01:08:56.967402Z  WARN yazi_adapter::emulator: [Adapter] No special environment variables detected
    at yazi-adapter/src/emulator.rs:70

  2024-06-24T01:08:56.967429Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM_PROGRAM: 
    at yazi-adapter/src/emulator.rs:84

  2024-06-24T01:08:56.967431Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM: alacritty
    at yazi-adapter/src/emulator.rs:92

  2024-06-24T01:08:56.967658Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:101

  2024-06-24T01:08:57.049105Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:08:57.049409Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:08:57.052734Z ERROR yazi_scheduler::preload::prework: Preload task `magick` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

Ueberzug++ log

 _   _      _
| | | |    | |                                _     _
| | | | ___| |__   ___ _ __ _____   _  __ _ _| |_ _| |_
| | | |/ _ \ '_ \ / _ \ '__|_  / | | |/ _` |_   _|_   _|
| |_| |  __/ |_) |  __/ |   / /| |_| | (_| | |_|   |_|
 \___/ \___|_.__/ \___|_|  /___|\__,_|\__, |
                                       __/ |
                                      |___/     v2.9.6
[2024-06-23 22:08:57.037] [terminal] [info] TERM = alacritty
[2024-06-23 22:08:57.038] [terminal] [info] PTY = /dev/pts/1
[2024-06-23 22:08:57.038] [X11] [info] Canvas created
[2024-06-23 22:08:57.038] [main] [info] Listening for commands on socket /tmp/ueberzugpp-475661.socket
[2024-06-23 22:08:57.073] [main] [info] Command received: {"action":"add","identifier":"yazi","max_height":158,"max_width":330,"path":"/tmp/yazi/c88082833bbe31760b746a683471b9e8","x":160,"y":1}
[2024-06-23 22:08:57.103] [opencv] [info] loading file /tmp/yazi/c88082833bbe31760b746a683471b9e8
[2024-06-23 22:08:58.440] [main] [info] Exiting ueberzugpp
Mirkopoj commented 1 week ago

Those are fresh logs with no config, opening yazi right on the pdf that caused the problem. As you can see max_width is send as 330. That same command breaks Ueberzug (A Black frame is render that wont leave until the process is stoped), but changing max_width to 200 fixes it. The problem is that changing the max_width in yazi.toml only affects images, not pdf preview. So the only way I have to shrink the preview to fix it is to change Ueberzug scale.

sxyazi commented 1 week ago

I don't see any Ueberzug commands in yazi.log. Are you in debug mode?

sxyazi commented 1 week ago

And also upload a gif of the steps of https://yazi-rs.github.io/docs/image-preview#debug-ueberzug and your /tmp/yazi/c88082833bbe31760b746a683471b9e8 file

Mirkopoj commented 1 week ago

Oh, I'm sorry I'll re try in debug mode. But I don't understand what do you mean by "GIF demonstration of the above steps". Is it a srceenshot of ueberzug properlly showing the preview when launched with the expected command?

sxyazi commented 1 week ago

Yep, I want to see your terminal size and the relative position of ueberzug

Mirkopoj commented 1 week ago

c88082833bbe31760b746a683471b9e8.zip Ueberzug_rigth Ueberzug_wrong

Mirkopoj commented 1 week ago

max_width 200 makes Ueberzug not crash but it still looks wrong. /tmp/yazi/c88082833bbe31760b746a683471b9e8 is ziped because github won't allow it.

sxyazi commented 1 week ago

Run tput cols and tput lines

Paste the output here

Mirkopoj commented 1 week ago

yazi log

  2024-06-24T01:37:18.970112Z  WARN yazi_adapter::emulator: [Adapter] No special environment variables detected
    at yazi-adapter/src/emulator.rs:70

  2024-06-24T01:37:18.970178Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM_PROGRAM: 
    at yazi-adapter/src/emulator.rs:84

  2024-06-24T01:37:18.970190Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM: alacritty
    at yazi-adapter/src/emulator.rs:92

  2024-06-24T01:37:18.970503Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:101

  2024-06-24T01:37:19.039314Z DEBUG yazi_adapter::ueberzug: ueberzugpp rect before adjustment: Rect { x: 160, y: 1, width: 330, height: 158 }
    at yazi-adapter/src/ueberzug.rs:99

  2024-06-24T01:37:19.039411Z DEBUG yazi_adapter::ueberzug: ueberzugpp rect after adjustment: Rect { x: 160, y: 1, width: 330, height: 158 }
    at yazi-adapter/src/ueberzug.rs:101

  2024-06-24T01:37:19.039457Z DEBUG yazi_adapter::ueberzug: ueberzugpp command: {"action":"add","identifier":"yazi","x":160,"y":1,"max_width":330,"max_height":158,"path":"/tmp/yazi/c88082833bbe31760b746a683471b9e8"}

    at yazi-adapter/src/ueberzug.rs:112

  2024-06-24T01:37:19.131967Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:37:19.132269Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:37:19.144645Z ERROR yazi_scheduler::preload::prework: Preload task `magick` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

Ueberzug++ log

 _   _      _
| | | |    | |                                _     _
| | | | ___| |__   ___ _ __ _____   _  __ _ _| |_ _| |_
| | | |/ _ \ '_ \ / _ \ '__|_  / | | |/ _` |_   _|_   _|
| |_| |  __/ |_) |  __/ |   / /| |_| | (_| | |_|   |_|
 \___/ \___|_.__/ \___|_|  /___|\__,_|\__, |
                                       __/ |
                                      |___/     v2.9.6
[2024-06-23 22:37:19.037] [terminal] [info] TERM = alacritty
[2024-06-23 22:37:19.038] [terminal] [info] PTY = /dev/pts/1
[2024-06-23 22:37:19.038] [terminal] [debug] ioctl sizes: COLS=254 ROWS=66 XPIXEL=2540 YPIXEL=1386
[2024-06-23 22:37:19.038] [terminal] [debug] iterm2 is not supported
[2024-06-23 22:37:19.038] [terminal] [debug] X11 is supported
[2024-06-23 22:37:19.038] [terminal] [debug] Using fallback X11 window id 12582915
[2024-06-23 22:37:19.038] [terminal] [debug] X11 sizes: XPIXEL=2544 YPIXEL=1400
[2024-06-23 22:37:19.038] [terminal] [debug] padding_horiz=2 padding_vert=7
[2024-06-23 22:37:19.038] [terminal] [debug] font_width=10 font_height=21
[2024-06-23 22:37:19.038] [main] [debug] Wayland support not compiled in the binary
[2024-06-23 22:37:19.038] [X11] [info] Canvas created
[2024-06-23 22:37:19.038] [main] [info] Listening for commands on socket /tmp/ueberzugpp-506043.socket
[2024-06-23 22:37:19.073] [main] [info] Command received: {"action":"add","identifier":"yazi","max_height":158,"max_width":330,"path":"/tmp/yazi/c88082833bbe31760b746a683471b9e8","x":160,"y":1}
[2024-06-23 22:37:19.106] [opencv] [info] loading file /tmp/yazi/c88082833bbe31760b746a683471b9e8
[2024-06-23 22:37:19.145] [X11] [debug] Initializing canvas
[2024-06-23 22:37:19.145] [X11] [debug] Created child window 48234496 at (1602,28) with parent 12582915
[2024-06-23 22:37:19.146] [X11] [debug] Received expose event for window 48234496
[2024-06-23 22:37:21.245] [main] [info] Exiting ueberzugpp
Mirkopoj commented 1 week ago

yazi.log with max_width = 200

  2024-06-24T01:42:20.542716Z  WARN yazi_adapter::emulator: [Adapter] No special environment variables detected
    at yazi-adapter/src/emulator.rs:70

  2024-06-24T01:42:20.542778Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM_PROGRAM: 
    at yazi-adapter/src/emulator.rs:84

  2024-06-24T01:42:20.542790Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM: alacritty
    at yazi-adapter/src/emulator.rs:92

  2024-06-24T01:42:20.543167Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:101

  2024-06-24T01:42:20.611086Z DEBUG yazi_adapter::ueberzug: ueberzugpp rect before adjustment: Rect { x: 160, y: 1, width: 330, height: 158 }
    at yazi-adapter/src/ueberzug.rs:99

  2024-06-24T01:42:20.611206Z DEBUG yazi_adapter::ueberzug: ueberzugpp rect after adjustment: Rect { x: 160, y: 1, width: 330, height: 158 }
    at yazi-adapter/src/ueberzug.rs:101

  2024-06-24T01:42:20.611237Z DEBUG yazi_adapter::ueberzug: ueberzugpp command: {"action":"add","identifier":"yazi","x":160,"y":1,"max_width":330,"max_height":158,"path":"/tmp/yazi/c88082833bbe31760b746a683471b9e8"}

    at yazi-adapter/src/ueberzug.rs:112

  2024-06-24T01:42:20.717324Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:42:20.718068Z ERROR yazi_scheduler::preload::prework: Preload task `image` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

  2024-06-24T01:42:20.726162Z ERROR yazi_scheduler::preload::prework: Preload task `magick` returned 2
    at yazi-scheduler/src/preload/prework.rs:62

ueberzug.log

 _   _      _
| | | |    | |                                _     _
| | | | ___| |__   ___ _ __ _____   _  __ _ _| |_ _| |_
| | | |/ _ \ '_ \ / _ \ '__|_  / | | |/ _` |_   _|_   _|
| |_| |  __/ |_) |  __/ |   / /| |_| | (_| | |_|   |_|
 \___/ \___|_.__/ \___|_|  /___|\__,_|\__, |
                                       __/ |
                                      |___/     v2.9.6
[2024-06-23 22:42:20.610] [terminal] [info] TERM = alacritty
[2024-06-23 22:42:20.610] [terminal] [info] PTY = /dev/pts/1
[2024-06-23 22:42:20.610] [terminal] [debug] ioctl sizes: COLS=254 ROWS=66 XPIXEL=2540 YPIXEL=1386
[2024-06-23 22:42:20.610] [terminal] [debug] iterm2 is not supported
[2024-06-23 22:42:20.610] [terminal] [debug] X11 is supported
[2024-06-23 22:42:20.610] [terminal] [debug] Using fallback X11 window id 12582915
[2024-06-23 22:42:20.610] [terminal] [debug] X11 sizes: XPIXEL=2544 YPIXEL=1400
[2024-06-23 22:42:20.611] [terminal] [debug] padding_horiz=2 padding_vert=7
[2024-06-23 22:42:20.611] [terminal] [debug] font_width=10 font_height=21
[2024-06-23 22:42:20.611] [main] [debug] Wayland support not compiled in the binary
[2024-06-23 22:42:20.611] [X11] [info] Canvas created
[2024-06-23 22:42:20.611] [main] [info] Listening for commands on socket /tmp/ueberzugpp-509715.socket
[2024-06-23 22:42:20.641] [main] [info] Command received: {"action":"add","identifier":"yazi","max_height":158,"max_width":330,"path":"/tmp/yazi/c88082833bbe31760b746a683471b9e8","x":160,"y":1}
[2024-06-23 22:42:20.672] [opencv] [info] loading file /tmp/yazi/c88082833bbe31760b746a683471b9e8
[2024-06-23 22:42:20.707] [X11] [debug] Initializing canvas
[2024-06-23 22:42:20.707] [X11] [debug] Created child window 56623104 at (1602,28) with parent 12582915
[2024-06-23 22:42:20.708] [X11] [debug] Received expose event for window 56623104
[2024-06-23 22:42:21.712] [main] [info] Exiting ueberzugpp
Mirkopoj commented 1 week ago

tput cols => 254 tput lines => 66

sxyazi commented 1 week ago

Thanks for the info, I'll make a patch later to try and fix it

Mirkopoj commented 1 week ago

Ok, great. Thanks for the impressively fast responses. And great work with yazi!!

sxyazi commented 1 week ago

Should be fixed in https://github.com/sxyazi/yazi/pull/1200, please give it a try to see if it works for you!

Mirkopoj commented 6 days ago

Yes, it is fixed. Thanks for the help.