sxyazi / yazi

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

Seek [n] doesn't work as expected when n is below 5 #1328

Open yousef8192 opened 1 month ago

yousef8192 commented 1 month ago

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

terminator 2.1.2

yazi --debug output

```sh ##### ↓↓↓ Paste the output here: ↓↓↓ ##### Yazi Version: 0.2.5 (c65a14c 2024-04-23) OS: linux-x86_64 (unix) Debug: false Emulator Emulator.via_env: ("screen-256color", "tmux") Emulator.via_csi: Ok(Unknown([])) Emulator.detect: Unknown([]) Adaptor Adaptor.matches: X11 Desktop XDG_SESSION_TYPE: Some("x11") WAYLAND_DISPLAY: None DISPLAY: Some(":0") SSH shared.in_ssh_connection: false WSL /proc/sys/fs/binfmt_misc/WSLInterop: false Variables SHELL: Some("/bin/bash") 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.44\nmagic file from /etc/magic:/usr/share/misc/magic\n", stderr: "" }) Text Opener default: Some(Opener { run: "opener \"$@\"", block: true, orphan: false, desc: "Open", for_: None, spread: true }) block: Some(Opener { run: "opener \"$@\"", block: true, orphan: false, desc: "Open", for_: None, spread: true }) tmux TMUX: true Ueberzug++ Version: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" }) ```

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

No, and I'll explain why below

Describe the bug

It seems that n can't be set to a number below 5 (Maybe this is related to scrolloff? Although I did set scrolloff = 0 and still n can't get below 5) and setting it below 5 has no effect and the seek value is still 5.

What I tested is the latest release as of the time of writing this issue (Yazi 0.2.5 (https://github.com/sxyazi/yazi/commit/c65a14c0e650c92cce52fe507b9f84a873cae44d 2024-04-23) is the output of yazi --version). I am not really sure which build is considered the latest nightly build so I can't confirm if I tried it or not sorry. Please let me know which one is it and I will try it to see if the issue exists there too.

If any further information is needed please let me know. Thanks a lot for the amazing tool!!

Expected Behavior

When n is set to m where m is a number below 5, it actually seeks m units in the preview and not 5 units.

To Reproduce

Backup your keymap.toml and replace it with the following :

"$schema" = "https://yazi-rs.github.io/schemas/keymap.json"

[manager]

prepend_keymap = [

{ on = [ "<A-k>" ],     run = [ "seek -1" ],                                                desc = "Seek up 1 units in the preview" },
{ on = [ "<A-j>" ],     run = [ "seek 1" ],                                                 desc = "Seek down 1 units in the preview" },

]

Configuration

Tested without configurations except for what's mentioned in the "To Reproduce" Section.

Anything else?

No response

sxyazi commented 1 month ago

The parameters for seek are just rough estimates, not precise values, because it's impossible to achieve that in implementation - different previewers interpret these parameters in different ways.

For example, with PDFs, it's in pages with a unit of 1; with videos, it's in percentages with a unit of 5%; and with codes, it's the available window space divided by 10.

I'm not sure which previewer you're using, but you can check out the specific code here: https://github.com/sxyazi/yazi/tree/main/yazi-plugin/preset/plugins

The documentation for previewers is available here: https://yazi-rs.github.io/docs/plugins/overview#previewer

yousef8192 commented 1 month ago

Thanks for the clarification.

What about creating an option for text previews so that the unit is lines instead of in terms of the available window space so that both options are doable? I guess this could be done if there is a way to obtain the font size (specifically the height) of a single character in the terminal or something