A space before the cursor
I am on the latest Hyper.app version
I have searched the issues of this repo and believe that this is not a duplicate
OS version and name: macOS Sierra 10.12.2 Hyper.app version: 1.1.0
When my command prompt PS1 is loaded in Hyper it places one space before the cursor which leaves me confused when editing texts.
I tried editing the functions I use in my .bashrc to see if the space came from there but I didn't find it.
In my regular bashshell the extra space is not there.
This is the code I use to generate my PS1
` parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^]/d' -e 's/ (.*)/ (\1)/' }
parse_latest_commit() { git log -n 1 --pretty=format:"%H" }
ME_EMOJI=(🐶 🐱 🐭 🐹 🐰 🐸 🐯 🐨 🐻 🐷 🐮 🐵 🐼 🐙 🐧🐦🐤🍒🍈🍓😬😄😃😀☺️); RANDOM_ME_EMOJI=${ME_EMOJI[$((RANDOM%14))]};
export PS1="$RANDOM_ME_EMOJI \u \W [\033[32m]$(parse_git_branch)[\033[00m] => " `
I thought it was maybe BLOCK vs BEAM or one of the plugins. But no luck fixing it. Seems like an "off by one" error someplace.
I am experiencing the same issue when using tmux. Without tmux everything looks fine. macOS Sierra 10.12.3 zsh 5.3.1 + tmux 2.3 Hyper 1.1.0
Have you tried removing the emoji from your prompt? I've noticed this happens only with certain emoji. Might be something to do with how many unicode characters certain emoji actually are? i.e. some only take one, others take two, which might be confusing hyper about how much space it should occupy.
This actually happens to me as well, but only in tmux. Outside of a tmux session, everything aligns correctly.
Broken here too on OSX, but only in tmux.
I've had this for many months.
Broken for me too. I use the unicode 👻 "ghost in the shell" ps1 prompt. I work on web software localization so it's critical that my terminal fully support odd unicode characters.
In iterm it's fine, with or without tmux. In hyper with tmux there's 1 too little space and the 👻 overlaps the text. In hyper without tmux there's 1 too much space.
This is almost certainly related to the emojis - more specifically, wherever the app is counting the number of characters that have been output, it's likely using String.length, which counts the number of bytes in the string instead of the number of symbols.
For example: '👻'.length returns 2, because the 👻 needs five hex digits to specify, (1F47B), which means that it takes two bytes in a Javascript string to store it.
Now, to fix it! In ES6, the simplest way is to use Array.from('👻').length instead.
I'd also consider adding punycode as a dependency, as this is unlikely to be the only issue we run into with Unicode character support.
Thanks, I'll take a look. Not confident I'll find the best fix, but I'll work towards a pull request.
I found relevant code. It looks like hyper calls hterm-umdjs's charWidth method. hterm just has a TODO for supporting emoji widths.
https://github.com/zeit/hyper/blob/master/lib/hterm.js#L67 https://github.com/dbkaplun/hterm-umdjs/blob/master/dist/index.js#L4839
Great what you people found. Thanks a lot
I also have an emoji in my PS1 and am experiencing this issue - see https://gist.github.com/sebm/7392d2db5205ee6bf6b402e47ff0047f
FWIW I'm getting this in tmux in Hyper 1.3.1 with no custom emoji or character in my PS1. 😢
Can confirm that removing the emoji removes the space. Peculiar!
It's especially on emojis with several skin tones, because the information of the color needs some kind of extra space. Like explained from lyndsysimon above.