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
Issue rendering completion when longer than terminal size #2484
On OSX 10.10.5, in both iTerm2 and in Terminal. If I start to type a command that has a completion longer than the terminal window, I get quite odd behavior
After typing a single "s":
After typing a "c" from that state:
After typing backspace once:
After typing backspace again:
In this state, typing backspace any more doesn't do anything, so it seems like the state of what's being shown doesn't match the currently-typed characters.
If I resize the terminal window so the whole completion fits, I don't run into any issues.
Ah, and I tested for another important detail – this only happens when "Unicode East Asian Ambiguous Characters are Wide" is set in preferences. Perhaps something about the width of the "…" character changes and that throws it off?
Could you try a build from the current master? brew install --HEAD will work if you're using Homebrew. I wonder if #2217 has improved this at all (though I doubt it).
I think this is a dup of #1412 (thanks faho). Basically fish needs to know the current cursor position, which requires it to know the width of characters. But Terminal has a preference for how wide Unicode characters should be, and fish has no way of knowing what that setting is (AFAIK). So things can get out of sync.
FWIW, the reason this is relevant is that (in my experience) terminal Vim doesn't work right with wide Unicode characters without this setting on. This is actually true for a lot of terminals with Vim; I was pleasantly surprised when I realized that iTerm2 and OSX terminal allowed this. Even with all the combinations of ambiwidth=double etc. in .vimrc, in my experience it has needed help from the terminal to not have the Vim cursor either jank around on wide characters, or cut off half the rendering of truly wide characters.
But Terminal has a preference for how wide Unicode characters should be, and fish has no way of knowing what that setting is (AFAIK). So things can get out of sync.
Check just the delta in cursor position the VT100 way before and after printing out a multibyte character and you do learn the actual width that was used by the terminal emulator for that character. This technique:
Can take this further than the ambiguous characters, various terminals responsible for making up their own rules for wcwidth() given the lousy system implementations must have other departures and quirks...
If one so desired (there's no law against it) you can loop through every character in the printable ranges, giving the full mapping of desired wcwidth() output necessary to not cause problems.
The mosh guy once showed off a crazy, much less decipherable (just perl) version, that wildly tries everything up to UINT_MAX, unprintables be damned. Apparently the idea was to overwrite all of the wcwidth() values with a per-user table to get consistent behavior when local echoing while ssh'd to another machine running the other half of the software!
These are distances for Terminal.app on 10.11.4 if I run it: wcwidth.txt
Anyhow It seems practical to try that on one ambiguous character in a way not perceptible to the user in order to suss out the behavior selected in that setting or determined by the locale. Use that to determine what kind of counting fish uses until the locale changes, occasionally rechecking.
Activity
pickfire commentedon Oct 13, 2015
Hi, what is your output of
fish --version?jpolitz commentedon Oct 13, 2015
Oops, sorry:
fish, version 2.2.0jpolitz commentedon Oct 13, 2015
Ah, and I tested for another important detail – this only happens when "Unicode East Asian Ambiguous Characters are Wide" is set in preferences. Perhaps something about the width of the "…" character changes and that throws it off?
faho commentedon Oct 13, 2015
Compare #2224.
faho commentedon Oct 13, 2015
And the (wonderfully titled) #1412.
zanchey commentedon Oct 15, 2015
Could you try a build from the current master?
brew install --HEADwill work if you're using Homebrew. I wonder if #2217 has improved this at all (though I doubt it).jpolitz commentedon Oct 15, 2015
I don't see a difference with
fish, version 2.2.0-369-g9788566. Happy to keep myself on HEAD and try changes if you ping me, though.ridiculousfish commentedon Oct 15, 2015
I think this is a dup of #1412 (thanks faho). Basically fish needs to know the current cursor position, which requires it to know the width of characters. But Terminal has a preference for how wide Unicode characters should be, and fish has no way of knowing what that setting is (AFAIK). So things can get out of sync.
jpolitz commentedon Oct 15, 2015
FWIW, the reason this is relevant is that (in my experience) terminal Vim doesn't work right with wide Unicode characters without this setting on. This is actually true for a lot of terminals with Vim; I was pleasantly surprised when I realized that iTerm2 and OSX terminal allowed this. Even with all the combinations of
ambiwidth=doubleetc. in .vimrc, in my experience it has needed help from the terminal to not have the Vim cursor either jank around on wide characters, or cut off half the rendering of truly wide characters.floam commentedon Mar 11, 2016
Check just the delta in cursor position the VT100 way before and after printing out a multibyte character and you do learn the actual width that was used by the terminal emulator for that character. This technique:
https://github.com/jquast/blessed/blob/master/bin/detect-multibyte.py
Tada!
Can take this further than the ambiguous characters, various terminals responsible for making up their own rules for wcwidth() given the lousy system implementations must have other departures and quirks...
If one so desired (there's no law against it) you can loop through every character in the printable ranges, giving the full mapping of desired wcwidth() output necessary to not cause problems.
The mosh guy once showed off a crazy, much less decipherable (just perl) version, that wildly tries everything up to
UINT_MAX, unprintables be damned. Apparently the idea was to overwrite all of the wcwidth() values with a per-user table to get consistent behavior when local echoing while ssh'd to another machine running the other half of the software!These are distances for Terminal.app on 10.11.4 if I run it: wcwidth.txt
floam commentedon Mar 11, 2016
Anyhow It seems practical to try that on one ambiguous character in a way not perceptible to the user in order to suss out the behavior selected in that setting or determined by the locale. Use that to determine what kind of counting fish uses until the locale changes, occasionally rechecking.
floam commentedon Mar 12, 2016
Here's after East Asian Ambiguious characters are wide enabled:
wcwidth-ambigwide.txt
floam commentedon Mar 12, 2016
And a diff
floam commentedon Jul 5, 2016
Marking as fish-tanked bug. I guess we could write our own terminal emulator...
pickfire commentedon Jul 5, 2016
@floam, are you really sure about writting your own emulator, haha fish emulator
faho commentedon Mar 15, 2019
There's been a million changes to unicode handling, so I'm closing this.