You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OS X High Sierra: unicode in fish_prompt gets wrong length calculated #4539
fish version: 2.6.0 and fa57565
OS: OS X High Sierra, 10.13.1
After upgrading, having a unicode character in my prompt (along with a right prompt) has the size calculated incorrectly.
In the above screenshot, everything is normal when I have a fully ASCII prompt. When I source my fish_prompt to re-add the Unicode character, the cursor is positioned on the next line.
Everything was working normally before the update to High Sierra. It's not working in either iTerm or Terminal.
It looks as if fish doesn't account for character width when calculating the placement of the right prompt: Single-width characters are okay (even multi-codepoint characters are accounted for), yet for each beer, the right prompt gets shifted one more character onto the next line.
function fish_prompt
set beer (printf '\xF0\x9F\x8d\xba')
printf '%s' $beer$beer$beer
end
function fish_right_prompt
echo 0987654321
end
I'm able to reproduce in all terminals I have handy: xterm, gnome-terminal and weston-terminal.
Reacted by David Adam, Richard Stelling and Fabian Boehm
This works for me if I set HAVE_BROKEN_WCWIDTH to 0, i.e. rely on the OSs wcwidth. Maybe it's time to start relying on that again? It seems like the situation has improved dramatically.
This should be fixed in 5282d3e . Note that wcwidth isn't sufficient since Terminal and iTerm2 measure emojis differently, and even iTerm 2 allows this to be controlled with a preference. fish tries to guess the right emoji size, but this can be set by the user via fish_emoji_width in case fish guesses wrong.
Thanks for filing, please comment if you still see a problem. We can update the heuristic for any emulators that use width-2 emoji.
This should be fixed in 5282d3e . Note that wcwidth isn't sufficient since Terminal and iTerm2 measure emojis differently, and even iTerm 2 allows this to be controlled with a preference. fish tries to guess the right emoji size, but this can be set by the user via fish_emoji_width in case fish guesses wrong.
Thanks for filing, please comment if you still see a problem. We can update the heuristic for any emulators that use width-2 emoji.
@ridiculousfish reporting on latest master fish-2.7.1-1096-ga9e9af5c under GNOME Terminal 3.28.1 using VTE 0.52.1 under Arch Linux. Emojis behave bad by default, setting fish_emoji_width to 2 fixes the issue (see mandatory GIF below).
Can you update the heuristic? Looking at 5282d3e, here's what I found in env that could make sense to detect GNOME Terminal:
Set $fish_emoji_width to 2 if your system does Unicode >= 9 (most likely yes)
Set $fish_ambiguous_width to whatever width your terminal shows ambiguous characters at (in this case 2)
Don't use ambiguous characters of differing widths as that's not expressable.
In this case this character is of ambiguous width so do set -g fish_ambiguous_width 2 (after upgrading to fish 3 if necessary), or set your terminal to show ambiguous characters as narrow instead of as wide.
Activity
anordal commentedon Nov 16, 2017
Is that a double width character? Which codepoint(s) is it?
paulswartz commentedon Nov 17, 2017
It's🍺 'BEER MUG' (U+1F37A)
anordal commentedon Nov 17, 2017
It looks as if fish doesn't account for character width when calculating the placement of the right prompt: Single-width characters are okay (even multi-codepoint characters are accounted for), yet for each beer, the right prompt gets shifted one more character onto the next line.
I'm able to reproduce in all terminals I have handy: xterm, gnome-terminal and weston-terminal.
ridiculousfish commentedon Nov 27, 2017
Probably
fish_wcwidthneeds to be updated for emoji.faho commentedon Nov 27, 2017
This works for me if I set HAVE_BROKEN_WCWIDTH to 0, i.e. rely on the OSs wcwidth. Maybe it's time to start relying on that again? It seems like the situation has improved dramatically.
floam commentedon Nov 27, 2017
I agree, it seems now we are the ones with the lousy implementation. 🤕
wcandillon commentedon Dec 13, 2017
I'm having the same issue. For instance if I use an emoji in my git commit message, everything gets broken.
faho commentedon Dec 13, 2017
@wcandillon: Which emoji are you using? Can you try #4554?
rrrnld commentedon Jan 3, 2018
I'm facing the same issue, described in some greater detail here because I thought it had to do with my theme.
I pulled @faho's changes, built it (which worked after installing
doxygenmanually) and the error seems to be fixed:Nice!
Add fish_emoji_width variable to control computed emoji width
Add fish_emoji_width variable to control computed emoji width
Add fish_emoji_width variable to control computed emoji width
ridiculousfish commentedon Feb 26, 2018
This should be fixed in 5282d3e . Note that wcwidth isn't sufficient since Terminal and iTerm2 measure emojis differently, and even iTerm 2 allows this to be controlled with a preference. fish tries to guess the right emoji size, but this can be set by the user via
fish_emoji_widthin case fish guesses wrong.Thanks for filing, please comment if you still see a problem. We can update the heuristic for any emulators that use width-2 emoji.
Make wcwidth configurable
Make wcwidth configurable (#4816)
Make wcwidth configurable (fish-shell#4816)
ronjouch commentedon Apr 23, 2018
@ridiculousfish reporting on latest master fish-2.7.1-1096-ga9e9af5c under GNOME Terminal 3.28.1 using VTE 0.52.1 under Arch Linux. Emojis behave bad by default, setting
fish_emoji_widthto2fixes the issue (see mandatory GIF below).Can you update the heuristic? Looking at 5282d3e, here's what I found in
envthat could make sense to detect GNOME Terminal:Thanks for fish! 🙂
ridiculousfish commentedon Apr 24, 2018
Ugh, my Ubuntu 16.04 with gnome-terminal has 1-width emojis. I guess this depends on something else. Let me try to report the 2-width case.
jyn514 commentedon Oct 22, 2019
I have the same issue with '▶️ ' in my prompt. It should be 1, it seems to be 2.
faho commentedon Oct 22, 2019
@jyn514 The solution is always the same:
In this case this character is of ambiguous width so do
set -g fish_ambiguous_width 2(after upgrading to fish 3 if necessary), or set your terminal to show ambiguous characters as narrow instead of as wide.In future please open a new issue or come to https://gitter.im/fish-shell/fish-shell. This issue is old, closed and doesn't really apply to the specific question.