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

has a '%' in the top left, and themes has bugs in v3.0. #3586

Closed
2 tasks done
evolify opened this issue May 6, 2019 · 29 comments
Closed
2 tasks done

has a '%' in the top left, and themes has bugs in v3.0. #3586

evolify opened this issue May 6, 2019 · 29 comments

Comments

@evolify
Copy link

evolify commented May 6, 2019

  • 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:
  • Hyper.app version:
  • Link of a Gist with the contents of your .hyper.js:
  • Relevant information from devtools (CMD+ALT+I on macOS, CTRL+SHIFT+I elsewhere):
  • The issue is reproducible in vanilla Hyper.app:

Issue

@evolify
Copy link
Author

evolify commented May 6, 2019

image

@karolkozer
Copy link

Same here, version: Hyper 3.0.0 (stable)

@mcornella
Copy link

This appears to be a regression since it was fixed in v2: #2144 (comment).

@saintjcob
Copy link

Yes, I experience the same issue

@mcornella
Copy link

A git bisect run says cba4c66 is the first known bad commit.

@mcornella
Copy link

I've tinkered a bit more and it seems the culprit is that a 'session data' event is emitted when calling to initialSession.flushEvents(), with the data being the options.uid. Here's what I get if I console.log initialSession:

{ session:
   Session {
     _events:
      { data: [Function: handleData], exit: [Function: handleExit] },
     _eventsCount: 2,
     _maxListeners: undefined,
     pty:
      UnixTerminal {
        _internalee: [EventEmitter],
        _socket: [PipeSocket],
        _pid: 26028,
        _fd: 34,
        _pty: '/dev/pts/1',
        _file: '/usr/bin/zsh',
        _name: 'xterm-256color',
        _readable: true,
        _writable: true },
     batcher:
      DataBatcher {
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        uid: '5d504086-c418-4110-b83c-adcff74310c5',
        decoder: [StringDecoder],
        data: '5d504086-c418-4110-b83c-adcff74310c5',
        timeout: null },
     shell: '/usr/bin/zsh',
     ended: false },
  options:
   { rows: 40,
     cols: 100,
     cwd: '/home/marc',
     splitDirection: undefined,
     shell: '',
     shellArgs: [ '--login' ],
     uid: '5d504086-c418-4110-b83c-adcff74310c5' },
  flushEvents: [Function: flushEvents] }

And the only event in initialEvents:

console.log(`"${args[0]}": ${args[1]}`);
"session data": 5d504086-c418-4110-b83c-adcff74310c5

I don't know what any of this means but I hope it's helpful to you.

@jacobgraf
Copy link

Same issue here on 3.0 on Mac.

@esdotzed
Copy link

esdotzed commented May 6, 2019

+1

@esdotzed
Copy link

esdotzed commented May 6, 2019

This solution fixed it for me.
#2144 (comment)

@jackroi
Copy link

jackroi commented Jun 11, 2019

Same issue on Hyper 3.0.2, only in the first tab of each new window.
I don't want to use unsetopt PROMPT_SP, because I really like this ZSH feature.

@b-bot
Copy link

b-bot commented Oct 7, 2019

Same issue on Hyper 3.0.2, only in the first tab of each new window.
I don't want to use unsetopt PROMPT_SP, because I really like this ZSH feature.

Can you explain why you might want to keep this?

@rastating
Copy link

Same issue on Hyper 3.0.2, only in the first tab of each new window.
I don't want to use unsetopt PROMPT_SP, because I really like this ZSH feature.

Can you explain why you might want to keep this?

It's useful for being able to see if output ends with a new line whilst keeping a consistent feel / appearance to the prompt. In instances where there is no new line, the prompt will continue from the end of the previous output without a line break.

@Stanzilla
Copy link
Collaborator

Please try a CI canary build

@CsarGomez
Copy link

I have the same issue, any way to fix it?
Captura de Pantalla 2019-10-14 a la(s) 6 37 57 p  m

@Stanzilla
Copy link
Collaborator

That looks like an issue with your oh-my-zsh and not with hyper. looks like your font is missing a symbol or so?

@CsarGomez
Copy link

fix it after add :
unsetopt PROMPT_SP
to my .zshrc file

@b-bot
Copy link

b-bot commented Oct 15, 2019

That looks like an issue with your oh-my-zsh and not with hyper. looks like your font is missing a symbol or so?

This was present after a clean install of Catalina on my Hyper as well (as Catalina changed the default shell) and I had to use @CsarGomez fix above to remove it.

@imtbl
Copy link

imtbl commented Oct 15, 2019

This is not a problem with oh-my-zsh or missing symbols, so I think this issue shouldn't have been closed.

It occurs because hyper doesn't deal with zsh's option to preserve partial lines correctly (PROMPT_SP, see http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting), as has been mentioned before.

This wasn't the case in 2.x, so it must've been some change in 3.x that causes this incorrect behavior.

Using unsetopt PROMPT_SP is a workaround but not a fix, as the option can be quite useful as mentioned by another user.

Other terminal emulators I've tried so far on both macOS and Arch Linux (iTerm 2, Alacritty, kitty, Xfce Terminal) don't seem to suffer from this problem when using the same zsh settings.

@Stanzilla
Copy link
Collaborator

@Tyriar is that a xterm problem?

@jackroi
Copy link

jackroi commented Oct 15, 2019

The strange thing is that it only happens on the first tab, when I open a new tab it works.
So it's definitely a hyper problem.

@mcornella
Copy link

mcornella commented Oct 21, 2019

I can't reproduce this on 3.0.2 canary. I do can.

@jackroi
Copy link

jackroi commented Oct 21, 2019

I've just tested version 3.1.0-canary.1 on macOS and it works fine.

@romkatv
Copy link

romkatv commented Oct 27, 2019

The problem is that Hyper incorrectly reports terminal size for some short time after the tty is created. Try adding this at the very top of ~/.zshrc and then starting Hyper.

typeset LINES COLUMNS
sleep 1
typeset LINES COLUMNS

Here's what I get:

LINES=40
COLUMNS=100
LINES=20
COLUMNS=75

My real terminal width is 75 but Hyper says 100 for a short while. If my ~/.zshrc isn't bloated, then zsh will print the first prompt while thinking that the terminal is 100 characters wide. If prompt_cr and prompt_sp are set (this is the default), zsh will print the following sequence before every prompt.

  1. Bold % on inverted background. This is controlled by PROMPT_EOL_MARK. You can put PROMPT_EOL_MARK=X in ~/.zshrc to use the plain X character instead.
  2. N - M spaces, where N is the terminal width and M is the width of PROMPT_EOL_MARK (1 by default).
  3. \r (carriage return).
  4. Clear to the end of line (ce termcap).

If this sequence is printed when the cursor is at the very first column, it will simply clear the current line. If the cursor is not on the first column, it'll append % to the current line and move the cursor to the beginning of the next line.

Now let's see what happens when the terminal says it's 100 columns wide when it's actually only 75 columns wide. Instead of printing % followed by 74 spaces, \r and ce (which would have no effect), zsh will print % and 99 spaces. This will wrap around to the next line. The subsequent \r and ce will clear the second line but % on the first line will remain.

To see this in action, add this at the top of ~/.zshrc and start Hyper.

PROMPT'>>>'
RPROMPT='<<<'
return

image

Note: That pesky percent and mangled prompt.

This is not a bug in zsh. If you replace typeset LINES COLUMNS with /bin/stty size, you'll also get wrong data. Or you can even tell Hyper to start /bin/stty size bypassing the shell. It'll still report wrong terminal size.

I don't know much about Hyper but does it perchance use VTE? There is a VTE bug that causes very similar issues for all terminals that use it. See gnunn1/tilix#1777.

(Hyper doesn't export VTE_VERSION, so probably not using VTE?)

I've just tested version 3.1.0-canary.1 on macOS and it works fine.

If this is indeed a VTE bug, then it makes sense that you wouldn't see it on macOS. VTE is GNU, a part of GNOME.

I can't reproduce this on 3.0.2 canary.

Which OS?

I can reproduce it on Linux with VTE version 5605 and Hyper 3.0.2.

Edit: I think Hyper doesn't use VTE, so it's an unrelated bug. I've also reproduced this problem on macOS with Hyper 3.0.2.

@romkatv
Copy link

romkatv commented Oct 28, 2019

Zsh users affected by this bug can mitigate it by installing powerlevel10k theme and enabling instant prompt through p10k configure. If you still see broken prompt when starting Hyper, add sleep 1 at the end of ~/.zshrc. This won't make zsh startup slower thanks to instant prompt.

romkatv added a commit to romkatv/powerlevel10k that referenced this issue Oct 28, 2019
The bug in Hyper (vercel/hyper#3586) is
similar to the one in VTE but it takes Hyper at least 100 times
longer to report correct TTY (Hyper is slow in general, so this
isn't surprising.)
@jackroi
Copy link

jackroi commented Oct 28, 2019

The problem is that Hyper incorrectly reports terminal size for some short time after the tty is created. Try adding this at the very top of ~/.zshrc and then starting Hyper.

typeset LINES COLUMNS
sleep 1
typeset LINES COLUMNS

I tried to add this to the top of .zshrc, and as you pointed out, after opening a new Hyper 3.0.2 window (on MacOS), it reports an incorrect terminal size. Furthermore the size reported does not change even after the sleep command (I tried with sleep longer than 1 second, up to 10 seconds, too). Then, I realised that other Zsh features don't work, such as auto-completion, which is rendered strangely, just as if the size of the terminal did not match the actual size.
Here is a screenshot (my terminal size is 80x24):

hyper-1

While opening a new tab in the same window, the size is correctly reported and the autocompletion works as expected.

Then I tried the 3.1.0-canary.1 version of Hyper again.

hyper-canary

As you can see, the window size is correctly reported and in fact the % does not appear.

But when I use auto-completion (which in this version is rendered well), the command, in this case cd, is printed 2 times in the prompt. Probably this is an unrelated bug of this canary version.

Apparently in the canary the problem of the % sign has already been solved; another problem has emerged though...

@Pratik-Hub
Copy link

add unsetopt PROMPT_SP to your last line of .zshrc will simply solve it

@romkatv
Copy link

romkatv commented Nov 24, 2020

add unsetopt PROMPT_SP to your last line of .zshrc will simply solve it

This is a bad idea. Consider:

❯ unsetopt prompt_sp
❯ printf 'Hello World\nGoodbye' >message.txt
❯ cat message.txt
Hello World
❯ █

Note that the output of cat message.txt is missing the second line.

It's a really bad idea to unset PROMPT_SP in zsh.

@ssliman
Copy link

ssliman commented Mar 6, 2021

Go inside the .zshrc file at the top you'll find:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH <- uncomment this line

That's what worked for me

@VergeDX
Copy link

VergeDX commented Mar 28, 2021

I'm using https://github.com/fish-shell/fish-shell, sleep 0.7 in the end of file ~/.config/fish/config.fish fix this issues for me.
And I also measure the costed time, I found this will cause macOS Terminal slow opening time, but no influences on Hyper.

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