Scrolling in the integrated terminal using the mouse wheel

Viewed 1081

I am using the remote-ssh extension with a (remote) bash as integrated terminal in Visual Studio Code September 2021 release.

When I use the scroll wheel in the integrated terminal, I move through the bash command history (like if I were pressing the up/down arrow keys). Furthermore, there are no scrollbars in the terminal so I am not able to see the text that does not fit in the current viewport.

Is there any way I can use the scroll wheel to actually scroll the content of the integrated terminal window? If I remember correctly, with previous versions of the program I was able to do exactly what I am asking.

The support page https://code.visualstudio.com/docs/editor/integrated-terminal does not say anything about this.

I have another question: is there a place with a comprehensive list of settings for the integrated terminal?

Details:

Version: 1.61.0 (user setup)
Commit: ee8c7def80afc00dd6e593ef12f37756d8f504ea
Date: 2021-10-07T18:13:09.652Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043
Microsoft remote-ssh: version v0.65.8
1 Answers

The issue being described here is the "alternative screen buffer" which causes the scroll wheel to act as arrow keys, scrolling the shell history rather than the window.

If you execute a command (such as vim) that puts you in the "alternative screen buffer" but doesn't put you back when it exits, you can switch back from the alternative screen buffer with:

$ echo -ne '\x1B[?1049l'

# or, if you don't want to memorize that:
$ tput rmcup

If you really want to disable alternate screen buffer switching, which could cause other apps to behave very differently than you're used to which rely on the alternate screen buffer, you could create a new terminfo entry that removes the smcup and rmcup capabilities, which enables this capability.

For example, if you're using xterm-256color, you can create a xterm-256color-noalt terminfo entry like this:

$ infocmp xterm-256color | sed \
  -e 's/^xterm-256color/xterm-256color-noalt/' \
  -e 's/[rs]mcup=[^,]*,//' \
  >xterm-256color-noalt.ti

$ tic xterm-256color-noalt.ti

Then, set your TERM to xterm-256color-noalt:

$ export TERM=xterm-256color-noalt

But, this is a bit more drastic and, like I said, could cause other apps that depend on alternate screen buffer capability being available in the terminal to misbehave or at least behave in ways you don't expect.

Related