You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there are no terminals, and then a terminal is created and shown with the following code, the terminal is visible but vscode.windows.activeTerminal is still undefined. Once a second terminal has been created, activeTerminal works fine.
If 'My Terminal #2' is closed, activeTerminal correctly becomes 'My Terminal #1'. If this is closed, and the steps repeated, the message 'activeTerminal is undefined' will appear again.
Things DO work as expected if the terminal is created and shown with Terminal API: Create Terminal and Terminal API: Show, then verified with Terminal API: Check activeTerminal: this produces the message 'activeTerminal: Ext Terminal #1'. So it seems somehow specific to the code at the top of this issue.
Does this issue occur when all extensions are disabled?: Yes
I identified this while following up on a discussion at #105944. There are some activeTerminal issues that look related, like #53107, but I couldn't find one describing this problem.
The text was updated successfully, but these errors were encountered:
Tyriar
added
bug
Issue identified by VS Code Team member as probable bug
terminal
General terminal issues that don't fall under another label
labels
Sep 4, 2020
I'm the author of the Angular Schematics extension (400 000+ users), and I'm also facing an issue with unreliable vscode.window.activeTerminal.
But the issue seems much larger than what is described here, for me the activeTerminal API is totally buggy.
For short, my extension is using a terminal to launch Angular CLI commands, and I would like to switch back to the previously active terminal (generally there will be a terminal with npm start / ng serve running) once it's done. See cyrilletuzi/vscode-angular-schematics#396
So I'm storing vscode.window.activeTerminal to show it back after, but the value is rarely right.
For example, if I open a terminal, launch any command (like echo 'world'), then open another terminal (with the "+" button), launch any command, then use my extension, the first terminal will be displayed back instead of the second.
Things get more and more messier if I delete terminals, add new ones, switch between them, etc.
Seems to me there is a lot of cases where vscode.window.activeTerminal is not updated at all. When looking in the repo issues, I've seen quite of a lot of related issues closed while not really being fixed.
@Tyriar as you tagged this issue, do you know what's the status about this issue and this API in general?
I have tested in VS Code 1.53 too and the bug I reported no longer happens. The active terminal is now the visible terminal, as expected. I will close this issue. @Tyriar If you fixed this, thank you!
When there are no terminals, and then a terminal is created and shown with the following code, the terminal is visible but
vscode.windows.activeTerminal
is stillundefined
. Once a second terminal has been created,activeTerminal
works fine.Steps to Reproduce:
To try to make a minimal reproducible example, I have made a small change to one of the Extension Samples. You can see my modification to the Microsoft version here: https://github.com/microsoft/vscode-extension-samples/compare/master...andycraig:master?expand=1
Download/clone my version from https://github.com/andycraig/vscode-extension-samples/tree/master
File -> Open Folder... -> vscode-extension-samples/terminal-sample
Run -> Start Debugging
Close existing terminal
Command
Terminal API: Create & Show Terminal
Observe terminal appears, and message 'onDidOpenTerminal, name: My Terminal Open Source VS Code #1'
Command
Terminal API: Check activeTerminal
Observe message 'activeTerminal is undefined'
Unexpected, as 'My Terminal Open Source VS Code #1' is visible.
Command
Terminal API: Create & Show Terminal
Observe terminal appears, and message 'onDidOpenTerminal, name: My Terminal gulp-symdest does not preserve links on electron #2'
Command
Terminal API: Check activeTerminal
Observe message 'activeTerminal: My Terminal gulp-symdest does not preserve links on electron #2'
This is as expected.
If 'My Terminal #2' is closed,
activeTerminal
correctly becomes 'My Terminal #1'. If this is closed, and the steps repeated, the message 'activeTerminal is undefined' will appear again.Things DO work as expected if the terminal is created and shown with
Terminal API: Create Terminal
andTerminal API: Show
, then verified withTerminal API: Check activeTerminal
: this produces the message 'activeTerminal: Ext Terminal #1'. So it seems somehow specific to the code at the top of this issue.Does this issue occur when all extensions are disabled?: Yes
I identified this while following up on a discussion at #105944. There are some
activeTerminal
issues that look related, like #53107, but I couldn't find one describing this problem.The text was updated successfully, but these errors were encountered: