Skip to content

Tab completion problem #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
terry182 opened this issue May 19, 2016 · 44 comments
Closed

Tab completion problem #3

terry182 opened this issue May 19, 2016 · 44 comments
Assignees

Comments

@terry182
Copy link

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

@frm
Copy link
Member

frm commented May 19, 2016

What OS and terminal emulator are you running, so I can try to reproduce the issue?

@terry182
Copy link
Author

@frmendes I am using OSX El Capitan 10.11.5 (15F34). The emulator is the terminal.app (?

@frm
Copy link
Member

frm commented May 19, 2016

@terry182 I can't seem to reproduce it. I have the same OS version and tried on Terminal.app. It works on both Terminal and iTerm2 on my end. Can you try and disable other plugins you have (preferably one at a time) to see if there's some side effect created by the theme?

@terry182
Copy link
Author

@frmendes I didn't use any plugin as I just clean install my Macbook. But I notice that I am just using it as a theme, will that be the problem?

I just download the geometry.zsh and put it in ~/.oh-my-zsh/custom/themes and rename it.

FYI, I reproduce the result by pressing l, s, Tab in my end. Maybe this could help

@terry182
Copy link
Author

I found the problem happens to be the international setting Unicode East Asian Ambiguous characters are wide of terminal.

I guess this issue can be closed.

@IanCStewart
Copy link

@frmendes it seems that tab completion adds a character to the sentence
screen shot 2016-07-25 at 11 20 36
if you type anything and then tab it changes from for example git to ggit
this is just visual, the commands still get send without the extra

@frm
Copy link
Member

frm commented Jul 25, 2016

Does this happen by just typing <command> <tab>? What encoding are you using?

@IanCStewart
Copy link

IanCStewart commented Jul 25, 2016

it happens automatic when u type <command> <tab> & when you type <half command> <tab> and this half command has lots of possibilities. but not when you type <half command> <tab> and there is only one possibility. my encoding must be on the default don't know where to find this.

@frm
Copy link
Member

frm commented Jul 25, 2016

What terminal emulator and OS are you using?

@IanCStewart
Copy link

iTerm and osx El Capitan

@frm
Copy link
Member

frm commented Jul 26, 2016

You can check your encoding in Preferences > Profiles and then select the active profile (should probably the one with a ⭐️). Encoding is in the Terminal tab. Can you check it there, please?

@frm frm reopened this Jul 26, 2016
@IanCStewart
Copy link

@frmendes my encoding is on unicode (UTF-8)

@andreabedini
Copy link

I am experiencing the same issue as @IanCStewart :-/

@andreabedini
Copy link

I can reproduce this reliably on iTerm 3.0.5 when I open a new shell. Here is a sequence of screen shots where I type 'l' and keep pressing TAB (note that there's no available ll command). Disabling the theme returns to the correct behaviour.

screen shot 2016-08-16 at 9 42 12 am
screen shot 2016-08-16 at 9 42 20 am
screen shot 2016-08-16 at 9 42 31 am
screen shot 2016-08-16 at 9 42 38 am
screen shot 2016-08-16 at 9 42 49 am

@andreabedini
Copy link

Update, this only happens if I set export GEOMETRY_SYMBOL_PROMPT="♦︎"

@frm
Copy link
Member

frm commented Sep 5, 2016

@andreabedini @IanCStewart should be fixed by now. Sorry it took me so long.

It's ok on my end but can you confirm it, please? I'll re-open the issue if it persists.

@andreabedini
Copy link

@frmendes works now, thanks! all this is a bit above my head, could you say a word about why this was happening? btw I tried to hack a simple pyenv integration to your theme in 9b1c1ee

@frm
Copy link
Member

frm commented Sep 6, 2016

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.

@IanCStewart
Copy link

@frmendes looks like its working just doing some weird indenting jumping stuff now. ass u can see below first it has more space then the space disappears

screen shot 2016-09-06 at 17 23 57
screen shot 2016-09-06 at 17 24 08

@frm
Copy link
Member

frm commented Sep 6, 2016

That really shouldn't happen after the fix. Can you check if it happens with export GEOMETRY_SYMBOL_PROMPT="♦︎"? Besides that, can you provide the prompt character you are using?

@andreabedini
Copy link

just FYI I switched to ☁︎ and ☂ for GEOMETRY_SYMBOL_PROMPT and GEOMETRY_SYMBOL_EXIT_VALUE (thanks for the tip @IanCStewart!) and I can reproduce. The autocompleted command shifts left.

@frm frm reopened this Sep 8, 2016
@frm
Copy link
Member

frm commented Sep 8, 2016

I just pushed a fix for this.

There's a small caveat with it, though. Using unicode characters means I have to calculate the size of the prompt character. In some cases, such as ☁︎, zsh has some issues figuring out the prompt character columns and a space gets added after the prompt.

However, this only happens with some characters, as far as I could tell, which means I don't have a fix for it. It should be solved on a case-by-case basis, changing the prompt_geometry_render function on geometry.zsh to add/remove any extra space.

If someone finds a fix for that, I'd really appreciate.

@frm frm closed this as completed Sep 8, 2016
@steinybot
Copy link

steinybot commented Nov 14, 2017

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

@frm frm self-assigned this Nov 28, 2017
@goliatone
Copy link

I'm having the same issue, removing the docker_machine plugin then it seems to work ok. Also, updating the value of GEOMETRY_SYMBOL_DOCKER_MACHINE to something else works

@frm
Copy link
Member

frm commented Feb 28, 2018

@goliatone @lox is any of you running High Sierra?

@lox
Copy link

lox commented Feb 28, 2018

Yup, sure am!

@goliatone
Copy link

Yes

@jedahan
Copy link
Member

jedahan commented Mar 1, 2018

So with inconsolata for powerline, that symbol seems to be 'double wide' I know almost nothing about unicode and font rendering, but thought I would share in case it would help someone who knows more.

@primalmotion
Copy link

primalmotion commented Apr 7, 2018

Hi,

not sure if it's the exact same issue, but mine is doing some weird stuff too

apr-07-2018 00-51-46

High Sierra, iTerm 3.1.5, Roboto Mono as font

I also tried to do this

export GEOMETRY_SYMBOL_PROMPT="o"
export GEOMETRY_SYMBOL_RPROMPT="o"
export GEOMETRY_SYMBOL_EXIT_VALUE="o"
export GEOMETRY_SYMBOL_ROOT="o"

And it does the same thing

@nath1as
Copy link

nath1as commented Jun 27, 2018

Hi,
I'm on termite and get this issue when trying to set my symbols bold with \e[1m . Is there any way around the issue?

@frm
Copy link
Member

frm commented Jun 28, 2018

Some news about this. The explanation is available in this comment and you can trace this back to f0973e9 which fixes it.

I didn't have this issue in Sierra, was finally able to upgrade to High Sierra and I am only able to reproduce it when I copy @steinybot 's character. Not when I hit cmd + ctrl + space and selected the thunder.

So I did the following in Ruby:

[1] pry(main)> steinybot_thunder = "⚡"
=> "⚡"
[2] pry(main)> apple_thunder = "⚡️"
=> "⚡️"
[3] pry(main)> steinybot_thunder == apple_thunder
=> false
[4] pry(main)> steinybot_thunder.codepoints
=> [9889]
[5] pry(main)> apple_thunder.codepoints
=> [9889, 65039]

I do believe nothing has changed in the meantime, it's about the different characters and their respective byte size. zsh has some issues calculating the byte size. The problem is that with @steinybot 's thunder emoji, there's only 1 byte in the string but probably it requires more than that in the screen? I'm not 100% sure on how UTF-8 works in this sense.

I'm not sure there is a fix required in this sense.

@primalmotion can you see if yours is related to #214 ?

EDIT: Apparently the thunders are not being displayed correctly in a code block. This is steinbot's thunder: ⚡. This is apple's: ⚡️. They look the same in the terminal but the byte size is different.

@frm
Copy link
Member

frm commented Jun 28, 2018

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

@frm
Copy link
Member

frm commented Jun 28, 2018

@n-a-t-h-i-a-s I added some proposals to support that in #216

@frm
Copy link
Member

frm commented Jun 29, 2018

Another update on apple emojis: 🌊 and 🤙 have one single codepoint, which means they share the same issue as the thunder I mentioned previously. I'm not sure how to handle this.

@jedahan
Copy link
Member

jedahan commented Aug 21, 2019

fixed in v2 i think

@frm
Copy link
Member

frm commented Jul 20, 2020

Here's a blast from the past.

This is currently happening to me by swapping the order of the plugins:

GEOMETRY_PROMPT=(geometry_newline geometry_path geometry_status)

With the above config, if I do ls<tab> it converts to lls. Still haven't quite got to the root of the problem

@frm frm reopened this Jul 20, 2020
@frm
Copy link
Member

frm commented Jul 20, 2020

Seems to be geometry_newline, the \r in particular.

GEOMETRY_PROMPT=(geometry_path geometry_status) works.

@jedahan
Copy link
Member

jedahan commented Jul 20, 2020

hmm i forget the history of why we needed \r - I believe it had to do with weird spacing with non-simple-width prompt

@jedahan
Copy link
Member

jedahan commented Jul 20, 2020

#100 related

I wonder if \r\n works

@jedahan
Copy link
Member

jedahan commented Jul 20, 2020

\n\r is even worse lol

@frm
Copy link
Member

frm commented Jul 20, 2020

So, \n doesn't work but \n\r does (I also tried \r\n and had a laugh as well). Assuming it has to do with string termination, we could go with \n\0 which does seem to work 🤔

Although I'm curious as to why

frm added a commit that referenced this issue Jul 20, 2020
See [this comment](#3 (comment)).
@frm
Copy link
Member

frm commented Jul 22, 2020

Fixed by #298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants