Replies: 8 comments 5 replies
-
@sharky98 Thats a codepoints from the PUA regions in unicode - they are unspecced by unicode on purpose, as they are meant to be application dependent. Therefore terminal emulators dont know, how wide such a char has to be rendered (and often just guess between 1 or 2 cells wide). Ideally we'd have an API to declare properties of PUA chars inkl. their widths, so apps could just load their stuff on-the-fly. But such an interface does not exist currently on any terminal emulator. Thats the theory part. Now to your char at hand: Your UTF-16 surrogate Thats awkward, because your issue suggests, that xtermjs would render it 2 cells wide (thus creating an empty cell behind). |
Beta Was this translation helpful? Give feedback.
-
@jerch Thanks for the quick answer. I just tried it in VSCode terminal. It seems to render it at 1 cell wide (although the # symbol seems to overlap a bit, but that part I attribute to the specific font I use: FiraMono Nerd Font, switching to the "Mono" variant remove that overlap, but not the extra space). I added a second segment using another symbol that is using a single code Other fonts The weird thing is that the extra space is not right after the symbol, but at the end of the string where it is used. To test this I used #, ~ and % at the end and start of each string (alternating for each consecutive strings). I also added the surrogate pair in a leading diamond to verify that the behaviour is constant when using oh-my-posh. Demonstrate extra space after end of string And to be thorough, I removed oh-my-posh and modified PS1=$'~Before~#\U000F00ED#~After~'
PS1+=$'%Another%>' PS1=$'~Before~#\Uf455#~After~'
PS1+=$'%Another%>' While using Windows Terminal, in both cases there is not extra space after the |
Beta Was this translation helpful? Give feedback.
-
For completeness, I also tried with a character that is not from PUA regions, but still needs surrogate pair. I used |
Beta Was this translation helpful? Give feedback.
-
@sharky98 Your output for your PS1 examples looks really broken and I am pretty sure, that it is not xtermjs' fault (cannot repro here). As you correctly noted, if xtermjs would apply wrong cell widths to the PUA char, the empty cell would have been right behind that char. Can you get the byte sequence sent from the PTY master to the terminal somehow? (Idk if thats possible in vscode, whether it allows to enable terminal debug logging...) |
Beta Was this translation helpful? Give feedback.
-
Thanks again for the quick feedback. This is getting a bit too advanced for my terminal knowledge 😅. I'll see what I can do. Also, to help me figure it out, when you say my PS1 is broken, what do you mean? Because other than overwriting the PS1 variable to test a surrogate pair, this is all default Ubuntu 24.04 bash config 🤔. Do you have/know an app that use the most "strip down" xterm to test this other than using VSCode? It does happen also in Tabby, but only for pwsh, not when using SSH sessions, however I have no idea what they changed between both session types. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Jupp, the demo looks good, ">" (62) is the last byte sent (same for me here). vscode has that extra space, wherever that comes from... Edit: Oh well, that space comes from |
Beta Was this translation helpful? Give feedback.
-
When I use a surrogate pair (such as
\udb80\udced
for thenf-md-calendar
icon), there is an extra space before the trailing diamond and after the content of the segment that does not get styled.I opened an issue in both terminal where this happens, but it seems they both use xterm, so I open an upstream issue here.
See JanDeDobbeleer/oh-my-posh#5706 for original report.
Details
Steps to reproduce
With oh-my-posh, use a surrogate pair in any segment such as below.
Beta Was this translation helpful? Give feedback.
All reactions