Skip to content
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

Character position twisted #895

Closed
soaringk opened this issue Jul 16, 2020 · 15 comments
Closed

Character position twisted #895

soaringk opened this issue Jul 16, 2020 · 15 comments

Comments

@soaringk
Copy link

soaringk commented Jul 16, 2020

Current Behavior

The characters shifted somehow when I press the Tab to complete the command.
Screen Shot 2020-07-16 at 4 32 31 PM

And it also happens when I try to move my cursor.
Screen Shot 2020-07-16 at 4 31 36 PM

Another weird behavior is that the cursor will quickly fall back one position after finishing initialization.
Screen Shot 2020-07-16 at 4 36 00 PM

Steps to Reproduce:

  1. download prezto and follow the instruction
  2. change zstyle ':prezto:module:prompt' theme to powerlevel10k

Context (Environment):

OS: macOS Catalina 10.15.5
Terminal: iTerm2, Terminal.app
manager: prezto

Detailed Description

This happens when I updated the powerlevel10k to the latest version.
I tried to record the screen using terminalizer, but it work smoothly in the rendered gif... I've no idea.

Did anyone get this problem?

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

  1. What is the output of typeset -p TERM?
  2. Have you tried following https://github.com/romkatv/powerlevel10k/blob/master/README.md#cursor-is-in-the-wrong-place ?

@soaringk
Copy link
Author

Thanks, I solved it by run p10k configure after installing the recommended font.

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

Well, this is probably caused by the ip, because when I uncomment this element, the same problem occurred.

I also tried to restore a backup and comment this element. Problem solved.

Any idea?

@soaringk soaringk reopened this Jul 16, 2020
@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

What is the output of the following command?

print -r -- ${icons[NETWORK_ICON]}

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

\uF877

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

  1. What is the output of typeset -p TERM?
  2. Have you tried following https://github.com/romkatv/powerlevel10k/blob/master/README.md#cursor-is-in-the-wrong-place ?

☝️

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

Thanks, I observe this:

+--------------------------------------------------------------------------------+
| ❯                                     ⇣10.26 B/s ⇡9.52 B/s 192.168.**.*   ─╯ |
+--------------------------------------------------------------------------------+

I tried to fall back to some old image, I get this from the following.

+---------------------------------------------------------------------------------------------------+
| ❯                                                        ⇣22.41 B/s ⇡21.09 B/s 192.168.65.3 ﯱ ─╯ |
+---------------------------------------------------------------------------------------------------+

Maybe something breaks after the v1.12.0?

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

If you want to show how it looks, you'll need to post screenshots. Posting just text doesn't work because my browser can render it differently from your terminal. Note that you don't need to censor the IP because it's on a private network.

If prompt is shorter/longer than the frame, you can find out which symbol is causing issues by copy-pasting a part of the prompt.

Also please follow the guide I linked above and try what it suggests. E.g., verify that you don't have the awful iTerm2 option to display ambiguous characters as double width turned on.

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

Thanks for reply.
I didn't turn on the 'Ambiguous characters are double-width' on iTerm2.

I found out the last character was considered as double width
Screen Shot 2020-07-16 at 7 44 17 PM

However, when I tried copy and pasting the character one by one, I found this.
Screen Shot 2020-07-16 at 9 04 30 PM

Screen Shot 2020-07-16 at 9 10 24 PM

I also tried the same thing in a docker image I built a while ago.

Screen Shot 2020-07-16 at 9 01 11 PM

print -r -- ${icons[NETWORK_ICON]}

As for this command, I get this in container:
Screen Shot 2020-07-16 at 9 06 49 PM

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

So the problem is that your terminal incorrectly displays \uF877 as a zero-width character. This character is from Private Use Area, so it must be displayed as single width. This is the same macOS low-level bug as in #241. You can follow the same instructions as in #241 (comment) to verify this (simply replace F878 with F877).

I'll need to change the default icon used by ip segment. It's unfortunately that I don't know which range of characters is affected by this macOS bug, so it's not clear which icon is safe to use as a replacement. Perhaps \uF50D? Can you verify that your prompt gets fixed if you add the following parameter to ~/.p10k.zsh?

typeset -g POWERLEVEL9K_NETWORK_ICON='\uF50D'

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

By the way, https://github.com/romkatv/powerlevel10k/blob/master/README.md#if-the-prompt-line-is-shorter-than-the-frame-and-is-mangled already describes your case. I wonder what could be made clearer so that you could identify it yourself.

@soaringk
Copy link
Author

typeset -g POWERLEVEL9K_NETWORK_ICON='\uF50D'

Screen Shot 2020-07-16 at 9 31 09 PM

By the way, https://github.com/romkatv/powerlevel10k/blob/master/README.md#if-the-prompt-line-is-shorter-than-the-frame-and-is-mangled already describes your case. I wonder what could be made clearer so that you could identify it yourself.

Sorry, I didn't know much about the encoding. I checked #241 and this is the result.
Screen Shot 2020-07-16 at 9 34 05 PM

So I thought this is caused by:

This can also happen if prompt contains glyphs designated as "wide" in the Unicode standard and your terminal incorrectly displays them as non-wide. Terminals suffering from this limitation include Konsole, Hyper and the integrated VSCode Terminal. The solution is to use a different terminal or remove all wide glyphs from prompt.

instead of a macOS low-level bug.

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

Maybe provide an example like typeset -g POWERLEVEL9K_NETWORK_ICON='\uF50D' could be helpful? It would be more straightforward if users can just see the difference themselves.

@romkatv
Copy link
Owner

romkatv commented Jul 16, 2020

Maybe provide an example like typeset -g POWERLEVEL9K_NETWORK_ICON='\uF50D' could be helpful? It would be more straightforward if users can just see the difference themselves.

I don't understand. Let's forget that I've asked this question.

I've replaced the default icon. Since you are using prezto, you won't pick up this fix until the next powerlevel10k release. You can keep POWERLEVEL9K_NETWORK_ICON in your config until then. Once you get the new version of powerlevel10k, you can remove this parameter.

@soaringk
Copy link
Author

soaringk commented Jul 16, 2020

I think I misunderstand the solution in #241. I should be able to identify the problem.

Screen Shot 2020-07-16 at 10 25 39 PM

Thank you for your reply.

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

No branches or pull requests

2 participants