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

Resizing the terminal while in the alt buffer will break the normal buffer #510

Closed
Tyriar opened this issue Jan 25, 2017 · 3 comments
Closed
Assignees
Labels
type/bug Something is misbehaving
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Jan 25, 2017

Downstream issue microsoft/vscode#19385

Steps to reproduce

  • Have some output in the terminal like from ls -l
  • Open vim
  • :q
  • You can still see the output from ls, good
  • Open vim again
  • Resize the terminal
  • :q
  • The vim text is still on screen, and I can't scroll to see the output from ls.
@Tyriar
Copy link
Member Author

Tyriar commented Feb 3, 2017

This is not as trivial as it looks. It's happening because the normal buffer is cleared in resize, this is done because without doing this it doesn't get resized which causes a lot of issues if the rows were reduced.

@mofux
Copy link
Contributor

mofux commented Feb 3, 2017

I noticed this when I was looking through the code the other day. When the alt screen buffer is created, the normal screen buffer is backed up to terminal.normal, but terminal.normal never seems to get modified, not even on resize. When we switch back to the normal buffer, the terminal.normal backup is restored.

InputHandler.ts - creating the alternate buffer
InputHandler.ts - restoring the normal buffer

But still, given the way the alt buffer is replaced by normal buffer, how can there still be any content from the alt buffer making its way back to the normal buffer? I assume this happens because we do not call terminal.reset() before restoring the normal buffer (notice terminal.reset() is called when the alt screen buffer is created). Is there a reason why terminal.reset() is not called?

@Tyriar
Copy link
Member Author

Tyriar commented Feb 3, 2017

normal = null means that the alt buffer becomes the normal buffer, so nothing happens when you switch back to the normal buffer after exiting vim. We probably want to call resize again after the normal buffer is switched in, reworking resize so it doesn't break when we call it again.

Tyriar added a commit to Tyriar/xterm.js that referenced this issue Aug 6, 2017
This brings in proper support to resize both buffers (xtermjs#510) and fixes an
exception that was caused by wrongfully not clearing the normal buffer when
resizing while the alt buffer is active.

There was an obscure bug in this that could have caused some great confusion
later on; When switching to the alt buffer, a hard terminal reset was performed
which tried to retain the buffers. However, because buffers was initialized in
the Terminal constructor to a new BufferSet, the Terminal.buffer convenience
pointer was pointing at a stale alt buffer which was the one actually being
used, not Terminal.buffers.alt.

Fixes xtermjs#842
Fixes xtermjs#510
@Tyriar Tyriar added this to the 2.9.1 milestone Aug 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is misbehaving
Projects
None yet
Development

No branches or pull requests

2 participants