microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

Terminal shouldn't be focused if file cannot be run #24382

Open injust opened 1 week ago

injust commented 1 week ago

Behaviour

The "Python: Run Python File" commands focus the terminal unnecessarily if the file cannot be run.

Steps to reproduce:

  1. Enable "Python › Terminal: Focus After Launch" (python.terminal.focusAfterLaunch)
  2. Create an unsaved Python file or a saved non-Python file
  3. Run the "Python: Run Python File" command
  4. You get the error message "The active file needs to be saved before it can be run" or "The active file is not a Python source file", but the terminal still becomes focused
injust commented 1 week ago

https://github.com/microsoft/vscode-python/issues/24396 is the root cause of this. See that issue for more details.