Task's new integrated terminals are always revealed when Python extension is active with python.terminal.activateEnvironment set to true
See original GitHub issuePlease search existing issues to avoid creating duplicates.
I found these interlinking issues on the topic: microsoft/vscode-python#3852 (links to vscode/66056, which is duplicate of vscode/65179) https://github.com/Microsoft/vscode/issues/65179 (references this to be an issue with vscode-python specifically => microsoft/vscode-python#3852) https://github.com/Microsoft/vscode/issues/66056 (duplicate of vscode/65179) However microsoft/vscode-python#3852 was closed and locked, without the actual problem being addressed properly in my opinion.
While the latest answer in microsoft/vscode-python#3852 from @DonJayamanne does seem to get rid of the issue, I fail to see how the python.terminal.activateEnvironment setting SHOULD be connected to it.
I am presuming the activation of the virtual environment reveals the terminal, however the two features seem like they should not be connected / should not interact. Having a task run within the configured virtual environment AND not showing/revealing its terminal when running it is a completely viable use-case in my opinion, but maybe I fail to see a connection?
Note that all of this only applies if a new integrated terminal is opened for the task’s output, not when a “shared” panel is ready to be re-used or if the task is using a “dedicated” panel that is still open from the last run of the task.
Hence the real issue here as far as I can tell would be why the activation of the virtual environment is bringing the task’s integrated terminal “to the front” (reveal).
Environment data
- VS Code version: 1.60.1
- Extension version (available under the Extensions sidebar): v2021.9.1230869389
- OS and version: Ubuntu 18.04.6 LTS, Kernel version: 4.15.0-156-generic
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.12
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv & virtualenvwrapper
- Value of the
python.languageServer
setting: “Pylance”
Expected behaviour
Even with “python.terminal.activateEnvironment” set to true and the “presentation.reveal” property of a task set to “never” I expect the terminal with the task output not to come into focus when running the task.
Actual behaviour
With “python.terminal.activateEnvironment” set to true, tasks with their “presentation.reveal” property set to “never” come into focus when the virtual environment is activated.
Steps to reproduce:
-
Activate the Python extension.
-
Create a task, e.g. (presentation.panel has been chosen as “new” because the issue only happens, when a new integrated terminal is opened for the task)
{ "label": "Simple Test", "type": "shell", "command": "echo \"foo\"", "presentation": { "reveal": "never", "panel": "new" }
}
-
Run the task
-
Observe how the terminal with the task’s output is revealed even though its presentation.reveal property is set to “never”
Logs
No output is shown in the Output panel, output of the task is shown in an integrated terminal instead (Correct behavior). No log messages are triggered by this in the developer console.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
While trying to create the repro, I might have discovered the problem in the extension. Looks like in some cases we call
terminal.show
. @alexr00 that overrides"reveal": "never"
correct?We have two activation paths, this one seems to be the culprit here: https://github.com/microsoft/vscode-python/blob/db8e1e2460e9754ec0672d958789382b6d15c5aa/src/client/common/terminal/activator/base.ts#L32
@luabud Is there any reason we need to show the terminal on activation? I am guessing not and this is just a remnant from how we had it from a long time ago.