-
Notifications
You must be signed in to change notification settings - Fork 937
Fix icons cut off in some terminal emulators #854
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ytang !
Awesome. This has been a pain for a long time. Interestingly this fix is quite simple. I never thought that this is a problem on our side...
The changes look good to me, but we should test this on other problematic Terminal Emulators (like Konsole) as well.
powerlevel9k.zsh-theme
Outdated
@@ -156,12 +156,12 @@ left_prompt_segment() { | |||
if [[ -n $6 ]]; then | |||
visual_identifier="$(print_icon $6)" | |||
if [[ -n "$visual_identifier" ]]; then | |||
# Add an whitespace if we print more than just the visual identifier | |||
[[ -n "$5" ]] && visual_identifier="$visual_identifier " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment why there is a whitespace before ending the foreground color?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
powerlevel9k.zsh-theme
Outdated
@@ -240,12 +240,12 @@ right_prompt_segment() { | |||
if [[ -n "$6" ]]; then | |||
visual_identifier="$(print_icon $6)" | |||
if [[ -n "$visual_identifier" ]]; then | |||
# Add an whitespace if we print more than just the visual identifier | |||
[[ -n "$5" ]] && visual_identifier=" $visual_identifier" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you here add a comment about the whitespace as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks for the swift approval! It works for Konsole, too. |
Just tested this in |
Conflicts were: - test/segments/command_execution_time.spec and test/segments/go_version.spec: All conflicts come from renaming color names on next (Powerlevel9k#703) and adding a whitespace to the Visual Identifier (Powerlevel9k#854) on master.
Conflicts were: - test/segments/command_execution_time.spec and test/segments/go_version.spec: All conflicts come from renaming color names on next (Powerlevel9k#703) and adding a whitespace to the Visual Identifier (Powerlevel9k#854) on master.
Thanks so much, @ytang! Also, kudos for searching through our previous bugs to see where else this issue has been mentioned, and what was discussed there. Thanks for the solid PR! |
Given @dritter's testing & approval, this PR will go into the next release. |
@dritter @ytang has this fix found a way to master? |
Yeah it was working for me to, but isn't now |
For terminal emulators such as suckless, the most common scenario of icons being cut off is the virtual identifier before the segment content, even though there is a space between the icon and the text. The reason is that we add color only to the icon but not to the space next to it. To fix it, just add color to both the icon and its neighboring space. It allows the terminal emulator to render the icon correctly without introducing any visual side effects.
Here is a screenshot showing the cut-off before (the first line) and after (the second line) applying the patch:
This is superior to existing workarounds mentioned in #231 #453 #794 since we do not need to waste an extra space.