romkatv / powerlevel10k

A Zsh theme
MIT License
46.4k stars 2.19k forks source link

Cursor position incorrect when using Laravel 10 with prompt element #2534

Closed jamesdeacon closed 9 months ago

jamesdeacon commented 9 months ago

When the Laravel prompt element is turned on and Laravel 10 is installed, the cursor shows up in the incorrect position, see screenshot for more detail. On top of this the Laravel version number is also showing in the incorrect color, it should be showing in red as it does for all other Laravel versions.

image
romkatv commented 9 months ago

What terminal is this and what is the output of locale?

jamesdeacon commented 9 months ago

Screenshot is from iTerm but I see the same behaviour on MacOS Terminal.

Output of locale is:

LANG="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_ALL=
romkatv commented 9 months ago

Does the output of the following command contain colored bits? Could you post a screenshot?

php artisan --version

This needs to be run in the project directory.

jamesdeacon commented 9 months ago

Yes it does, and it matches the color used in the prompt element.

image
romkatv commented 9 months ago

Wow. They'll probably fix this so that colors aren't written when stdout is not a TTY, but in the meantime I can add a workaround.

Please send me the output of the following command. Hopefully it'll be the last one I'll ask you to run.

printf '%q\n' "$(php artisan --version)"
jamesdeacon commented 9 months ago

Sure thing, here's that output:

image

Just for reference, php artisan --version outputs the color on projects that are on Laravel 9 too but the cursor is in the correct position and the color on the prompt element is correct too

image
romkatv commented 9 months ago

Fixed. Please update powerlevel10k and verify whether it now works correctly for you.

Just for reference, php artisan --version outputs the color on projects that are on Laravel 9 too but the cursor is in the correct position and the color on the prompt element is correct too

Apparently, versions prior to 10 don't have this bug: they output colors only when the stdout is a TTY. You can verify this with php artisan --version | cat. The output should not have colors but with 10.40.0 it does.

jamesdeacon commented 9 months ago

I've installed powerlevel10k using brew. What's the best way for me to update seeing as brew is showing as up-to-date

romkatv commented 9 months ago

You could ditch brew for now and use the manual installation option, at least until I cut a new release.

  1. Comment out this line in ~/.zshrc:
    source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme
  2. Run this:
    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
    echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
  3. Restart zsh with exec zsh.
jamesdeacon commented 9 months ago

I've done that and it's not showing a Laravel version at all anymore:

image

This is also the case on any Laravel projects, not just Laravel 10.

I still have the laravel_version set in my POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS

image
romkatv commented 9 months ago

🤦‍♂️ https://github.com/romkatv/powerlevel10k/commit/f5d5abfe1f89e5ea0d6f7cde6f3d9cd4b7c89d14

Please try again.

jamesdeacon commented 9 months ago

Hooray! All working

image

Thanks so much

romkatv commented 9 months ago

Thanks a ton for you help on this issue: from reporting and remote debugging to verifying and even catching the silly bug I pushed! <3