hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Emoji in PROMPT is causing character duplication after pressing TAB

Open jkulak opened this issue 7 years ago • 14 comments

  • [x] I am on the latest Hyper.app version
  • [x] I have searched the issues of this repo and believe that this is not a duplicate
  • OS version and name: macOS Mojave 10.14.3 (18D109)
  • Hyper.app version: 2.1.2 (stable)
  • Link of a Gist with the contents of your .hyper.js: https://gist.github.com/jkulak/1633a8c0572aade642f050be97b1da76
  • Relevant information from devtools (CMD+ALT+I on macOS, CTRL+SHIFT+I elsewhere):
  • The issue is reproducible in vanilla Hyper.app: yes

Issue

I am using Hyper.js and oh-my-zsh. My PROMPT has an emoji (which causes the issue).

When I type a part of a command and press TAB to complete the command - and I get a list of suggestions for completion, the first letter of my command gets duplicated. Typing ls and pressing TAB gives:

šŸ¦€ ~ lls
LSCOLORS   ls         lsa        lsappinfo  lsbom      lskq       lsm        lsmp       lsof       lsvfs

When I type dock and the only option to autocomplete is docker it works just fine, and pressing TAB shows šŸ¦€ ~ docker. Pressing TAB again gives

šŸ¦€ ~ ddocker
docker                         docker-compose                 docker-credential-osxkeychain  docker-machine

Pressing enter runs docker command and not ddocker so it's only a visual issue.

The issue occurs only with an emoji in the PROMPT. Issue doesn't occur in iTerm nor in Terminal.

jkulak avatar Mar 09 '19 19:03 jkulak

Similar experience for me, and I also only experience it when I have an emoji in the prompt.

I am using Hyper and Bash. I don't see the issue on autocomplete (tab), but I do see it when I hit the UP arrow to go to previous commands. The first UP pulls in the previous command, the second UP has the previous command's first letter prefixing it (visual only; the command will run properly).

Example:

šŸ• ~ vim .
šŸ• ~ du -sh Downloads/
(hit UP arrow)
šŸ• ~ du -sh Downloads/
(hit UP again)
šŸ• ~ dvim .

stripedpajamas avatar Mar 11 '19 19:03 stripedpajamas

Still the same in Hyper.app version: 3.0.0 (stable)

jkulak avatar May 08 '19 21:05 jkulak

I am getting the same issue in 3.0.2 (stable) on macOS mojave (version 10.14.4 (18E226)) with a simple prompt running the built-in bash (which is of course old, v3.2.57)

export $PS1="šŸ”­> "

a hexdump (echo $PS1 | hexdump) gives

0000000 f0 9f 94 ad 3e 0a                              
0000006

This doesn't cause an problem for iTerm, so it's not a bash specific thing.

Oh and it seems to not mind unless the command you scroll through has more than one word, at least for me. so scrolling through echo is find, but scrolling through echo "hi" will make a persistent e on the terminal

johnarban avatar May 12 '19 05:05 johnarban

in case it helps anyone else out... @romkatv offered a fix for hyper/zsh misinterpreting an emoji's width in a zsh prompt: https://github.com/robbyrussell/oh-my-zsh/issues/7945#issuecomment-508724741

Essentially: PROMPT='%{%GšŸ¦€%}'

zhao-li avatar Jul 05 '19 21:07 zhao-li

Any idea on how to fix when you actually write on ZSH, like a shell commit with an emoji?

elegos avatar Nov 04 '19 10:11 elegos

Any idea on how to fix when you actually write on ZSH, like a shell commit with an emoji?

It's a bug in Hyper so it needs to be fixed in Hyper.

romkatv avatar Nov 04 '19 11:11 romkatv

I know it's a Hyper bug, that's why I'm here. As the last comment is of the 5th of July I was wondering if anything can actually be made to fix it.

elegos avatar Nov 04 '19 22:11 elegos

I know it's a Hyper bug, that's why I'm here. As the last comment is of the 5th of July I was wondering if anything can actually be made to fix it.

Apparently no one is working on fixing this bug. You can either fix it yourself and send a PR, induce someone else to fix it, or wait and hope that others will do the work of fixing/inducing.

romkatv avatar Nov 05 '19 10:11 romkatv

Hey there, to verify if this is indeed a Hyper issue or upstream at https://github.com/xtermjs/xterm.js/ could you please test if another xterm.js powered terminal shows the same problem you are experiencing? I suggest using https://github.com/Microsoft/vscode for testing. Thanks!

Stanzilla avatar Nov 05 '19 13:11 Stanzilla

@Stanzilla if the VSCode terminal uses xterm.js, it seems to be an xterm.js problem (same issue). I'm going to open a bug there.

elegos avatar Nov 06 '19 13:11 elegos

I can confirm that the integrated terminal in VSCode also incorrectly prints šŸ¦€ as if it was a narrow character.

image

Here's how it's supposed to look like (same font and shell but in GNOME Terminal):

image

romkatv avatar Nov 06 '19 14:11 romkatv

Yup, going to close this then.

Stanzilla avatar Nov 06 '19 17:11 Stanzilla

@Stanzilla if the VSCode terminal uses xterm.js, it seems to be an xterm.js problem (same issue). I'm going to open a bug there.

Can you please link the issue you reported for xterm.js?

jkulak avatar Jan 21 '20 08:01 jkulak

PROMPT='%1{šŸ¤–%} ' did the trick for me, could somebody confirm?

Credit to: https://unix.stackexchange.com/questions/90772/first-characters-of-the-command-repeated-in-the-display-when-completing

philippnoah avatar Feb 26 '20 17:02 philippnoah