Skip to content

Issue rendering completion when longer than terminal size #2484

Closed

Description

@jpolitz

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":

screen shot 2015-10-12 at 9 50 14 pm

After typing a "c" from that state:

screen shot 2015-10-12 at 9 50 46 pm

After typing backspace once:

screen shot 2015-10-12 at 9 51 22 pm

After typing backspace again:

screen shot 2015-10-12 at 9 52 09 pm

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.

Activity

  1. pickfire commented on Oct 13, 2015

    @pickfire
    Contributor

    Hi, what is your output of fish --version?

  2. jpolitz commented on Oct 13, 2015

    @jpolitz
    Author

    Oops, sorry: fish, version 2.2.0

  3. jpolitz commented on Oct 13, 2015

    @jpolitz
    Author

    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?

    screen shot 2015-10-13 at 3 17 56 pm

  4. faho commented on Oct 13, 2015

    @faho
    Member

    Compare #2224.

  5. faho commented on Oct 13, 2015

    @faho
    Member

    And the (wonderfully titled) #1412.

  6. zanchey commented on Oct 15, 2015

    @zanchey
    Member

    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).

  7. jpolitz commented on Oct 15, 2015

    @jpolitz
    Author

    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.

  8. ridiculousfish commented on Oct 15, 2015

    @ridiculousfish
    Member

    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.

  9. jpolitz commented on Oct 15, 2015

    @jpolitz
    Author

    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.

  10. floam commented on Mar 11, 2016

    @floam
    Member

    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:

    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

  11. floam commented on Mar 11, 2016

    @floam
    Member

    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.

  12. floam commented on Mar 12, 2016

    @floam
    Member

    These are distances for Terminal.app on 10.11.4 if I run it (ambiguous are narrow): wcwidth.txt

    Here's after East Asian Ambiguious characters are wide enabled:
    wcwidth-ambigwide.txt

  13. floam commented on Mar 12, 2016

    @floam
    Member
  14. added
    bug
    on Jul 5, 2016
  15. added this to the milestone on Jul 5, 2016
  16. floam commented on Jul 5, 2016

    @floam
    Member

    Marking as fish-tanked bug. I guess we could write our own terminal emulator...

  17. pickfire commented on Jul 5, 2016

    @pickfire
    Contributor

    @floam, are you really sure about writting your own emulator, haha fish emulator

  18. faho commented on Mar 15, 2019

    @faho
    Member

    There's been a million changes to unicode handling, so I'm closing this.

  19. modified the milestones: fish-future, fish 3.0.0 on Mar 15, 2019
  20. 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

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions