Skip to content

Unicode support broken (was This ⸻ unicode ⸻ character ⸻ makes ⸻ weird ⸻ things ⸻ happen) #2652

Closed

Description

@iirelu

U+2E3B ⸻ THREE-EM DASH

image

Steps to reproduce:

  1. Copy that unicode character
  2. Type "test" (or anything for that matter)
  3. Paste repeatedly

What happens: Some sort of exponential growth? Pressing ^C doesn't get rid of it.

Expected results: Not that.

I've tested this in every terminal emulator I have, and it shows up in all of them (even xterm). No other shell has this problem.

Activity

  1. faho commented on Jan 4, 2016

    @faho
    Member

    This seems similar to #2199, no?

  2. zanchey commented on Jan 4, 2016

    @zanchey
    Member

    Yes, and I think also #750.

  3. terlar commented on Jan 4, 2016

    @terlar
    Contributor

    I don't experience the same thing, but instead the color of the dash gets all weird, guess it is due to the overlapping. I don't see any repetition of other characters.

    I am using termite on arch linux.

  4. added this to the fish-future milestone on Jan 6, 2016
  5. ridiculousfish commented on Jan 6, 2016

    @ridiculousfish
    Member

    This failure mode is when fish's idea of where the cursor is gets out of sync with where it actually is. This can come about if fish thinks a character is single width but it's actually double width, or vice versa.

    My font doesn't seem to have this character :(

  6. xiaq commented on Jan 25, 2016

    @xiaq
    Contributor

    There are two things you can do to contain the effect of the disparity between wcwidth and the actual terminal: 1) turn off autowrap whenever the editor is in control (echo '\033[?7l' to turn off, '\033[?7h' to turn on) and insert returns explicitly; 2) always re-render whole lines, from left to right, when the buffer changes. This way the line number is always correct and you minimize your dependency on the column number.

    I hope the advice is useful. :)

  7. pickfire commented on Jan 26, 2016

    @pickfire
    Contributor

    @xiaq Hi, I didn't know you are back.

    @terlar, what font are you using? @ridiculousfish and I too actually doesn't have that character.

  8. pickfire commented on Jan 26, 2016

    @pickfire
    Contributor

    @jakwings I didn't know that those two fonts isn't in my package manager. Trying to install it manually.

  9. terlar commented on Jan 26, 2016

    @terlar
    Contributor

    Yes, I think this glyph comes from the symbola package. Not sure which one it fallbacks to. But I know I have symbola to cover these kind of things.

  10. krader1961 commented on Mar 25, 2016

    @krader1961
    Contributor

    I can't reproduce the problem using iTerm2 on OS X without a font installed that supports that character. So I see the single width undefined char glyph. Is it possible a recent change (such as the one I made to support the C locale better) has "fixed" this? Can anyone reproduce this problem using a fish built from git head? If so can you provide better directions for reproducing the problem than was in the original comment?

  11. krader1961 commented on Jun 19, 2016

    @krader1961
    Contributor

    After installing Symbola (from http://www.fonts2u.com/symbola.font) I can reproduce this. It's pretty clear that fish is using the wrong char width. From https://en.wikipedia.org/wiki/Dash:

    Less common are the two-em dash (⸺) and three-em dash (⸻), both added to Unicode with version 6.1 as U+2E3A and U+2E3B.

    So our fish_wcwidth() implementation is out of date.

    P.S., It isn't just that character which renders weirdly. The Symbola font is ugly --- at least as handled by OS X Terminal.app. The inter-char spacing is just awful; even for plain ASCII chars.

  12. floam commented on Jun 19, 2016

    @floam
    Member

    It shouldn't be necessary to actually select Symbola as your font. Just install it and it will be used for odds and ends (like ⸻) with a regular terminal font selected.

    For me this font+character does the same thing as the double-width emojis in the just-closed #750 -- just a bigger difference in width with this example.

  13. krader1961 commented on Jun 19, 2016

    @krader1961
    Contributor

    FWIW, fish_wcwidth() returns 1 and the OS X El Capitan (10.11.6) wcwidth() returns -1.

    For me this font+character does the same thing as the double-width emojis in the just-closed #750

    That's weird because on my system that emoji renders as a single-width char in both Terminal.app (where I explicitly made Symbola the primary font) and iTerm2 using Consolas. However, in both of those multiple instances of that char overlap each other. So it's pretty clear it should be treated as double-width but fish and my terminals are treating it as single-width.

  14. 69 remaining items

  15. ridiculousfish commented on Jul 10, 2018

    @ridiculousfish
    Member

    @spacekookie emoji widths seem to be working pretty well on fish master (which includes a new wcwidth per #5081) with kitty terminal. You'll want to set emoji width to 2:

    `set -g fish_emoji_width 2`
    

    Please give it a try and report back! Really appreciate your patience with this.

  16. albinekb commented on Aug 14, 2018

    @albinekb

    I got emojis to work with fish, version 2.7.1-1337-g09541e95 by unchecking Use Unicode version 9 widths in iTerm2.app settings:
    image

  17. ridiculousfish commented on Aug 19, 2018

    @ridiculousfish
    Member

    I'm confident this has been addressed via the fish_emoji_width variable. Closing.

  18. albinekb commented on Aug 20, 2018

    @albinekb

    @ridiculousfish so always when setting up fish we need to remember to set the variable to get emojis to work? Doesn't seem very "user friendly"..

  19. faho commented on Aug 20, 2018

    @faho
    Member

    so always when setting up fish we need to remember to set the variable to get emojis to work?

    Maybe. That's the point of the variable existing - some terminals/systems need it set to 2 and some to 1. In particular, you'll have to set it to 2 if your terminal is using the Unicode 9 widths, and to 1 otherwise - which means even with e.g. iTerm2, it depends on that option you talked about! Which means we can't do terminal detection via $TERM and friends like we do for e.g. cursor shape or truecolor support.

    Doesn't seem very "user friendly"..

    Unfortunately, there's nothing fantastic we can do, simply because there is no way for us to communicate with the terminal to figure out what width it uses. The variable is very much an admission of that fact.

    It might be better to swap the default around - currently if you don't set that variable, we're using the pre-9 widths. Maybe it might be better to use the post-9 ones, or maybe we should wait another year or so until operating systems have caught up?

  20. ridiculousfish commented on Aug 21, 2018

    @ridiculousfish
    Member

    Yeah these variables are super-lame, but there's no other option. The best we can hope for is excellent defaults (can still improve here) and fallback configurability.

    I would guess the variable has the correct default sense today but could easily be wrong. Importantly though it only affects emoji that are in Unicode 8 or earlier (surprisingly few!). Emoji introduced in Unicode 9+ are always assumed to render per Unicode 9 widths.

  21. terlar commented on Aug 21, 2018

    @terlar
    Contributor

    The best idea I can come up with would be to have an interactive function where the user is presented with a unicode character displayed with the two different settings and can select which one looks best, that would then automatically set and persisted as the fish_emoji_width. Would that be possible?

  22. zanchey commented on Aug 21, 2018

    @zanchey
    Member

    That sounds like a good enhancement - would you or anyone else be interested in producing something?

  23. faho commented on Aug 21, 2018

    @faho
    Member

    I would guess the variable has the correct default sense today but could easily be wrong.

    So, glibc got updated in 2.26, which was released on 2017-08-02, so about a year ago. For Ubuntu, that means everything after 17.10 does Unicode 9.

    Notably, that leaves Ubuntu 16.04 (which is still supported and the current basis for WSL) and current Debian Stable out. I suspect other distributions to work the same, and I don't know how this works on macOS.

    So that's basically a worst-case answer. Large parts of our user base are using older distributions, especially on servers, so I can't be sure that switching defaults will make it work for more users.

    Alternatively we could do version-detection of the C library, but that might be too confusing given that there's often two knobs to deal with (the terminal's and ours) and keep in sync.


    The best idea I can come up with would be to have an interactive function where the user is presented with a unicode character displayed with the two different settings and can select which one looks best

    When is this shown? Does the user explicitly execute it? Is it a first-launch "wizard"?

    Still, this might be the best idea we've seen so far. Just a simple

    ❤
    aa
    
    Is the heart as wide as 1 or 2 "a"?
    

    (with the heart symbol being the last \U escape I used - no idea if that's affected by this)

  24. z3ntu commented on Aug 21, 2018

    @z3ntu
    Contributor

    When is this shown? Does the user explicitly execute it? Is it a first-launch "wizard"?

    Maybe show it the first couple of times under the Welcome to fish, the friendly interactive shell message and after it was executed / displayed 10 times(?), hide it?

  25. ridiculousfish commented on Aug 26, 2018

    @ridiculousfish
    Member

    To be sure, emoji width is not up to the C library, but instead the terminal. (I wouldn't be surprised if it were font dependent too.)

    I really like the idea of a "compatibility quiz" function! We could use it to detect support for 256 colors, 24-bit color, settable titles, and emoji widths.

  26. YaLTeR commented on Aug 26, 2018

    @YaLTeR

    Here's another idea for a quiz function:

    👉👉👉👉                            1   2
    Please select the following answer: ^
    

    With width = 1 the ^ points at "2" and with width = 2 it points at "1".
    image
    image

  27. floam commented on Dec 18, 2018

    @floam
    Member

    Instead of quizzing the user, I think we could quiz the terminal by using an escape to get the cursor position before and after printing a spooky character.

  28. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions