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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken Rendering of Characters Composed of Multiple Code Points in kitty #3600
Comments
Thanks, your analysis looks correct. tmux, like GNOME terminal, does not currently support this feature. Until it does, I suggest you either avoid the characters, or configure Kitty not to do this. If you (or anyone else) want to look at adding this, the implementation would not be very difficult - it is just a form of combining characters which is already supported (look at how ZWJ is handled in |
Possibily we could assume I don't think there is a similar way to get this information from libc... I think we would need a table. It would be nice if it was a (server) option - people are occasionally complaining that their custom PUA codepoints have the wrong width and an option would let them set their own widths as well as fixing up new Unicode versions without having to upgrade/restart tmux.
|
You can also try this (against master): tmux-codepoint-widths.diff.txt It adds an option
I thought of including these in the option by default, but it appears there are other major terminals that do not support this yet so perhaps that is premature... For these specific characters it may be better to just hardcode a list and add a terminfo(5) capability, but maybe that is overkill. |
Thanks a lot for the quick response, Nicholas! I tested the diff, and it does indeed resolve the issue in my first comment (#3600 (comment)). However, there still seems to be an issue with Unicode characters that are composed of multiple code points (e.g., 馃嚜馃嚫 which is composed of If we run kitty (without tmux): kitty + tmux: However, if we open kitty (without tmux): kitty + tmux: In this case, I don't think we can unconditionally set the widths of |
All programs must agree on the widths: terminal, tmux and vim. If they don't agree, things will look funny. If you configure these characters to be width 2 in tmux, you will need to configure vim in the same way, or tmux will move the cursor more or fewer positions than it expects. |
Yes, I understand that, but for certain code points, I don't think the widths can be statically specified in In the case of the Armenian flag, we want 馃嚘 to have a width of 1 but 馃嚥 to have a width of zero. In the case of the Moroccan flag, we want 馃嚥 to have a width of 1, but 馃嚘 to have a width of 0. When the code points are separated (e.g., by a space between them), we want each of them to have a width of 1. Therefore, I don't think we should statically define the width of the code points in What do you think? |
Perhaps we could use |
Yes we would need the ability to specify codepoint sequences rather than individual codepoints, and tmux would need to be able to understand "this codepoint might be followed by X or Z" in the same way as it does for keys. I don't really like depending on utf8proc because that means it won't work without it. |
Can you please try this: tmux-unicode.diff.txt This adds a
It works for me but this is very much a work in progress:
|
Thanks for continuing to work on this, Nicholas! I applied the patch in #3600 (comment) on top of 237ee6f. This works as expected when tmux-unicode-bug.webm |
Show the tmux server log please. If it works with |
Using I recorded a new session: tmux-unicode-bug.webm.webmHere are the logs associated with the recording above: tmux-client-30064.log |
I meant if it is correct without vim and still correct after |
Yes, outside of neovim, the text is properly aligned when running |
Sorry for the delay here. I am not sure nvim is sending the same characters as actually in the file. Can you open the text file in nvim in |
I had a look at this change again, and I think we will need to do it a different method. The problem is that these newer changes to Unicode are badly designed, particularly for stream protocols. If tmux gets a U+1F44D, it has no way to know whether it should be shown as it is or whether it will be followed by U+1F3FB. So we can't do this the way I had intended, it will need to work like zero width characters where it goes back and replaces the original character when it sees the new one. |
There are actually only a couple of hundred of these characters, so we could just list them and work out whether to combine based on the list. Please try this instead of the last diff (only lightly tested, eg I didn't try ZWJ): tmux-unicode-new.diff.txt You should not need to do any configuration for this (there is no option anymore). |
ZWJ still seems to work, for example But please test and see if it works for your symbols. |
Thanks for looking into this again! I applied the diff on top of 237ee6f, but it still didn't work. Here's a video of the issue: tmux-unicode-bug.webmNoteworthy in the video is how Similarly, opening outside tmux: Are you able to replicate this at your end? Here's some information that might help with replicating:
|
It works for me. Are you sure you applied the diff and were running the right tmux binary? If so please show tmux logs from running Please also show me the |
My bad! I accidentally applied an older diff. Sorry for the confusion. I applied the new diff (#3600 (comment)) on top of e3a8b84. There still seems to be an issue. Here's the result of outside tmux: inside tmux: Here are the logs from running tmux-client-15010.log The issue with displaying the characters in neovim also persists: outside tmux:
inside tmux:
During the testing, I was using |
This log is not from the right build either, can you please check you are running the right binary? The server log should contain the text nvim moves the cursor around inside the characters but I will look at that later. |
You are absolutely correct! I forgot that my For outside tmux: inside tmux: Here are the logs from running tmux-client-2283.log With tmux + neovim, there is a problem with the flag and the color of the colored thumbs-up emoji. outside tmux:
inside tmux:
When inside tmux, the problem with the colored thumbs-up emoji in neovim is resolved after highlighting the line in neovim:
|
OK test.txt works for me but if I do this it is wrong:
The reason is that the kernel and utf8proc both think this character is width 1.
However, it appears your terminal and mine both think that the character is width 2. I don't know if any terminals will make this width 1, so we could probably just force them to width 2. Try this please: tmux-unicode-combine.diff.txt I think I know what is wrong with vim but I am not going to work on that right now until this is working. |
I have applied this to OpenBSD now since it works for me, it will be in GitHub later. Let me know if you see any further problems with this part of it. Now I'll have a look at vim... |
I made this fix as well and now trying your script file from vim does not misbehave (I have applied this change also). Can you let me know if you still see problems either by applying it as well as the last diff, or wait until GitHub syncs?
|
@nicm The recent commits (in master) break multiple apps using utf box drawing characters. Here's a screenshot from fzf combining before and after: EDIT: This sometimes does not happen in leftmost pane for same application, but always does in right pane of a vertical split. |
Am I meant to guess which characters? Where are the logs? |
@nicm Ah, I thought you would have fzf installed, since it's so famous. Here are the logs: tmux-client-35806.log |
Does this fix it?
|
Never mind, it is a different bug, please try this or wait for it to reach GitHub:
|
@nicm Yes, the latest patch of yours fixes it. Thanks! |
I'm going to close this to get it out of the way but please let me know if you still see issues with vim and I will reopen. Thanks! |
Sorry for my (very) late reply, and thanks a lot for all your work on this, Nicholas! I tested the latest changes at For outside neovim, here is exactly how to reproduce:
Here are the tmux logs for this session: For inside neovim:
Here are the tmux logs for this session: Here are the inside_tmux.script.txt Software Versions:
|
It's worth noting that the issue is not just about cosmetics. For example, when editing The cursor is positioned correctly with |
Ah, it looks OK for me because iTerm2 has DECSLRM so the way tmux does cursor positioning is different and this hides the problem. It was working but I broke it by accident, please try this:x.diff.txt |
No, I'll have a look at vim at some point. |
Is this better? I was trying to get away from reaching into the existing data to check if we need to combine because that is going to be slow, but I think that is what we will have to do: width.diff.txt |
Don't bother with that one, it doesn;t work with actual zero width characters, will send a new one later. |
Try this please: width2.diff.txt I'm not wild about calling |
Thanks for quickly looking into this, Nicholas! I applied the latest diff to 9f9156c and cannot reproduce the issue anymore 馃帀 |
OK I have applied this now, please let me know if you see any further problems. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Characters composed of multiple Unicode code points (e.g.,
馃憤馃徎
which is composed ofU+1F44D
andU+1F3FB
) do not render properly when running tmux inside kitty.Steps to Reproduce
kitty --config NONE
.printf "Test\t\t|\n'馃憤' Test\t|\n'馃憤馃徎' Test\t|\n" > test.txt
.cat test.txt
.|
characters are aligned properly.tmux -vv -f /dev/null new
.cat test.txt
.|
characters are misaligned.This example is not drastic, but this bug causes problems when typing commands with multi-code-point characters in the shell or editing files with multi-code-point characters in vim/neovim: (kovidgoyal/kitty#6355 (comment)).
Screenshots
kitty without tmux:
kitty + tmux:
Gnome Terminal:
Gnome Terminal + tmux:
Environment Details
tmux version (
tmux -V
):tmux 3.3a
$TERM
inside tmux (echo $TERM
):tmux-256color
$TERM
outside tmux (echo $TERM
):xterm-kitty
kitty version (
kitty --version
):kitty 0.28.1 created by Kovid Goyal
Platform (
uname -sp
):Linux unknown
(Arch Linux)Logs
Logs of starting tmux in kitty using
tmux -vv -f /dev/null new
and runningcat test.txt
followed byexit
:tmux-client-14609.log
tmux-out-14611.log
tmux-server-14611.log
Potential Culprit
kitty combines a character with multiple code points per the Unicode standard. That is, it combines
U+1F44D
andU+1F3FB
and displays 馃憤馃徎 instead of 馃憤 followed by 馃徎. It seems like tmux expects that those two code points will be displayed separately. The mismatch between the character width that tmux expects and the width that kitty actually uses causes this issue.Additional Context
The relevant bug on the kitty side: kovidgoyal/kitty#6355.
The text was updated successfully, but these errors were encountered: