sxyazi / yazi

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

Small icons in Kitty due to missing space #906

Closed majutsushi closed 4 months ago

majutsushi commented 4 months ago

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

Kitty 0.33.1

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

Tried, but the problem still

yazi --debug output

```sh $ yazi --debug Yazi yazi 0.2.4 (VERGEN_IDEMPOTENT_OUTPUT 2024-03-10) Environment OS: linux-x86_64 (unix) Debug: false Emulator Emulator.via_env: ("xterm-kitty", "") Emulator.via_csi: Ok(Kitty) Emulator.detect: Kitty Adaptor Adaptor.matches: Kitty tmux TMUX: false Zellij ZELLIJ_SESSION_NAME: None Desktop XDG_SESSION_TYPE: Some("x11") WAYLAND_DISPLAY: None DISPLAY: Some(":0") Ueberzug Version: Ok(Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "Usage:\n ueberzug layer [options]\n ueberzug library\n ueberzug version\n ueberzug query_windows PIDS ...\n" }) WSL /proc/sys/fs/binfmt_misc/WSLInterop: false -------------------------------------------------- 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/jan/.local/state/yazi" directory. ```

Describe the bug

This bug is already mentioned at https://yazi-rs.github.io/docs/faq#why-icons-shrink, however I think I figured out what the problem is. The same kind of bug was recently filed in relation to joshuto: https://github.com/kovidgoyal/kitty/issues/7292

This pointed me towards Kitty's --dump-bytes option, which indicated that the problem in yazi is the same: in some cases there's no space after an icon. For icons that have the right size the bytes are <Esc>[38;2;137;224;81m <Icon> <Esc>[39m<filename>, whereas for incorrectly sized ones it is <Icon><Esc>[24;23H<filename>. So there is a space missing after the icon, causing it to have the wrong size. I haven't had time to check the code but hopefully this should be easy to fix.

Expected Behavior

Icons need a space after them so they have the right size

To Reproduce

Run yazi in Kitty without a flavor configured

Configuration

No response

Anything else?

No response

sxyazi commented 4 months ago

I'm not quite sure if I understand you correctly. If you're referring to the space around the icon text, indeed there is space:

https://github.com/sxyazi/yazi/blob/5fc2789c78c23dde40c71be446da7d4cfe45b302/yazi-plugin/preset/components/file.lua#L3-L12

majutsushi commented 4 months ago

That's interesting, because in the actual byte output the space isn't there. I suspect it gets replaced with the cursor positioning escape code <Esc>[24;23H at some later point. I don't know where that's coming from, I can't really immediately see its purpose. I'd like to dig deeper but I probably won't have time for that in the next few days.

sxyazi commented 4 months ago

Does the text line of this file you copied from the TUI contain spaces?

sxyazi commented 4 months ago

I just tested using the latest version of kitty and the latest Yazi code, but couldn't reproduce the issue.

It's possible that it has been fixed from either side. What version of kitty are you using? I noticed you are not using the latest Yazi code. Could you try the latest Yazi code to see if the problem has been resolved?

majutsushi commented 4 months ago

I can still reproduce it with Kitty 0.33.1 (the latest release) and the latest Yazi commit, but only under certain conditions that I haven't been able to reduce to a simple reproducible example yet. I'll try to have a closer look next week.

majutsushi commented 4 months ago

What I've discovered so far is that it happens for completely unstyled icons (i.e. icons for unknown filetypes with the default config) that also otherwise haven't had any kind of styles applied, for example once I have "hovered" over such a file (and thus applied the "reverse" style) it has the right size, even after I've moved the selection to another file.

I don't think it is the "styling" itself that is responsible for this, I think the act of styling just replaces the cursor positioning escape code I mentioned above with a space. Why that happens I don't really know though.

sxyazi commented 4 months ago

Hmm I'm not quite sure how to resolve it, it seems the only thing Yazi can do (as per kitty's requirement) is to add spaces around the icons, but I've already added it, though the requirement is quite weird, and kitty is the only terminal I know of that requires this.

So I prefer keeping the current solution, i.e. adding it to the FAQ, and suggesting users use a flavor to "workaround" it. I'm going to close this issue, if you find more clues that can help resolve, please reply to this issue, and I will reopen it.

SolitudeSF commented 4 months ago

though the requirement is quite weird, and kitty is the only terminal I know of that requires this.

because other terminal will leak glyphs into neigboring cells which is often even more broken.

if yazi isnt sending cursor reposition, then its probably ratatui that is doing that. strange that it stays fixed after being hovered.

SolitudeSF commented 4 months ago

yep, drawing Paragraph::new(" ") from ratatui reproduces this.

github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.