question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Task's new integrated terminals are always revealed when Python extension is active with python.terminal.activateEnvironment set to true

See original GitHub issue

Please 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:

  1. Activate the Python extension.

  2. 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"
     }
    

    }

  3. Run the task

  4. 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:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
karthiknadigcommented, Sep 23, 2021

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?

1reaction
karthiknadigcommented, Sep 23, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Task's new integrated terminals are always revealed when Python ...
Task's new integrated terminals are always revealed when Python extension is active with python.terminal.activateEnvironment set to true #17508.
Read more >
python - VS Code integrated terminal not starting with virtual ...
Created virtual environment in project directory using command python3 -m env . Modified setting in Python extension, "python.venvPath": "bin", ...
Read more >
Settings Reference for Python - Visual Studio Code
Specifies whether to activate the currently open terminal when the Python extension is activated, using the virtual environment selected. Specifies the level ...
Read more >
Visual Studio Code (Mac) - Setting up a Python Development ...
In this Python Programming Tutorial, we will be learning how to set up a Python development environment in VSCode on MacOS.
Read more >
Getting Started - Ohio Supercomputer Center
While Linux supports desktop graphical user interface configurations (as does OSC) in most cases, file manipulation will be done via the command line....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found