Change:
if (this._terminalService.terminalInstances.length > 0) { this._updateFont(); this._updateTheme(); <ins> this._terminalService.getActiveTab()?.setVisible(visible); </ins> } else { // Check if instances were already restored as part of workbench restore if (this._terminalService.terminalInstances.length === 0) {

Discussion:
Issue Type: <bBug</bReopening of steps the intergrated terminal. a command that generates more than one screen of content: to bottom run emacs and then close emacs using ctrl+c ctrl+x Bug Terminal scroll position is sometimes reset to top of buffer ! VS Code version: Code - Insiders 1.40.0-insider (, 2019-11-06T16:56:25.487Z) OS version: Darwin x64 18.7.0 <details<summarySystem Info</summary </details<!-- generated by issue reporter --
Can't repro some things that might help diagnose: Debug VS Code to see what's getting hitting hit. Calls to this when exiting would be particularly interesting Try repro in the demo Enable escape sequence logging and capture the entering emacs logs and exit emacs logs for both the case where it's fine and the case where the scroll is off.
Seems to happen most reliably when I run emacs as the git editor, but as the screenshot shows it can also happen for normal runs. From debugging: Normal case called with called twice with not called by Bugged case called with called with called again called by with
That's definitely the problem, could you get the stacktrace for both of those?
Stacks look the same. Here called with : ! : And with : ! It seems like a timing issue. Between the call to which sets and , someone else is setting . Here's one possible call sequences I see opening emacs in the bad case (true/false is the value of ): ! And from the good case: ! For what it's worth, I also currently see this more often in insiders (vs OSS)
I don't use emacs or something, just run some tests which output a lot of stuff, then hide and unhide terminal - after a couple of moments I am on top of terminal. Scrolling it with a scrollbar to the bottom doesn't bring me to the last line, so I press enter
Yeah, I have to press enter to get to the bottom of the terminal. I can confirm that this is an issue with Linux and Windows (I see this on both), so it doesn't appear to be specific to any OS. This also happens with both native and remote development, so it is not specific to remote development (which I use a lot).

For me, it starts happening after about an hour of use, and then becomes really frequent (almost every time I open the terminal). Its causing me to form a habitual response to just always press enter when I open the terminal :frowning_face:
Another repro:
The case seems to be a symptom of the TerminalPanel onDidChangeVisibility callback not triggering a setVisible call on the active terminal instance. The code to re-sync the the Terminal viewport and scrollbar is in the TerminalInstance setVisible method. I'm not sure if it's the same issue as the Emacs variation of the bug.
I'm also having this issue. When I toggle open the terminal on WSL and PowerShell, the terminal is scrolled to the top, even with all extensions disabled. I'm not using emacs - it happens reliably regardless of the type of content in the terminal. Just focusing on the terminal doesn't have this behavior, only toggling it does.
Update: for anyone looking for a temporary fix, I used the extension "multi-command" and set up a shortcut to scroll the terminal to the bottom when opening it. Since I needed to first focus the terminal after opening it, I had to set up two cases, toggling when it's closed and toggling when it's already open: "multiCommand.commands": [ { "command": "multiCommand.toggleTermClosed", "sequence": [ "", "", "", ] }, { "command": "multiCommand.toggleTermOpen", "sequence": [ "", ] } ]`
verified with steps from