geometry: Tab completion problem
I am having a problem using this theme when I try to tab complete
so it’s like
▲ .oh-my-zsh/custom/themes ls
and after tab completion it becomes
▲ .oh-my-zsh/custom/themesls
I tried to modify the theme but failed. Really can’t figure out where the problem is
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 44 (24 by maintainers)
Commits related to this issue
- Fix geometry_newline. See [this comment](https://github.com/geometry-zsh/geometry/issues/3#issuecomment-661360487). — committed to geometry-zsh/geometry by frm 4 years ago
To be honest, it was something pretty new to me as well. The relevant change is this line.
When you are using some special characters, like
♦︎
, the terminal has a hard time determining their true width.Zsh checks the full width of the prompt in order to place each character in the correct column of a line. With some characters, especially unicode, there was a tendency to over-estimate the character width.
If you Google around for
zsh tab completion duplicate character
you’ll find a lot of recomendations saying to wrap the troublesome part in%{...%}
to escape some color code sequences. This tells zsh the color codes have zero-width: they should be interpreted but don’t occupy on-screen space, which intuitively makes sense.However, if you try this in geometry, in the line I previously linked, you’ll see that it starts ignoring the space after the prompt character, unless you are on a git repo. This ticked me off because it meant the width of the character assumed by zsh was definitely wrong.
Instead, I had to explicitly tell zhs the width of the prompt character, by wrapping it in
%1{...%}
.I wouldn’t have noticed it only happened with specific prompt characters without your comment, thanks for that one!
As for your comment, feel free to open a PR!
I’m not sure I want to bind geometry, to any particular language, which means I’d eventually put something for rbenv/rvm and nvm as well. I’m on the fence on how fast the version check is as well. geometry is starting to get a bit slow, especially in large repos. Maybe something as discussed in #6 would come in handy for this.
If you do open the PR, I’d like to discuss some options.
@fribmendes This seems to have reappeared after updating to macOS High Sierra v10.13.1 using iTerm2 v3.1.5. It works perfectly fine in Terminal. It was also working fine before updating the OS. The particular character that I have found that doesn’t work is ⚡ (U+26A1).
@n-a-t-h-i-a-s bold is a bit more difficult. If I do
GEOMETRY_SYMBOL_PROMPT="\e[1mA"
then zsh detects the byte size as 6. However it should only occupy one symbol on screen (A
). I’ll try to get around this and see what I can do.