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

Small icons in Kitty due to missing space #906

Closed
majutsushi opened this issue Apr 13, 2024 · 10 comments
Closed

Small icons in Kitty due to missing space #906

majutsushi opened this issue Apr 13, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@majutsushi
Copy link

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

$ 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: kovidgoyal/kitty#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

@majutsushi majutsushi added the bug Something isn't working label Apr 13, 2024
@sxyazi
Copy link
Owner

sxyazi commented Apr 13, 2024

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:

function File:icon(file)
local icon = file:icon()
if not icon then
return {}
elseif file:is_hovered() then
return { ui.Span(" " .. icon.text .. " ") }
else
return { ui.Span(" " .. icon.text .. " "):style(icon.style) }
end
end

@majutsushi
Copy link
Author

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
Copy link
Owner

sxyazi commented Apr 13, 2024

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

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Apr 13, 2024
@sxyazi
Copy link
Owner

sxyazi commented Apr 13, 2024

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
Copy link
Author

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.

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Apr 14, 2024
@majutsushi
Copy link
Author

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
Copy link
Owner

sxyazi commented Apr 25, 2024

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.

@sxyazi sxyazi closed this as completed Apr 25, 2024
@SolitudeSF
Copy link
Contributor

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
Copy link
Contributor

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

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants