Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"internalConsoleOptions": "openOnSessionStart" not working out of the box #529

Open
1Mark opened this issue Mar 27, 2022 · 6 comments
Open
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on

Comments

@1Mark
Copy link

1Mark commented Mar 27, 2022

Issue Type: Bug

Issue was originally raised on microsoft/vscode#146102
fyi @sandy081 @isidorn
microsoft/vscode-python#6159 introduced "internalConsoleOptions": "openOnSessionStart" but using this via one of the pre-existing python debug configurations doesn't work out of the box since it has a constraint.

Start debugging a new project or file, it will ask you to choose a debug config
2022-03-26 12_53_46-Window

If you choose this first option it gives

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        }
    ]
}

Then you realise you want the debug console to open automatically when you start the debugging, you come across microsoft/vscode-python#6159
then you add this to your config and

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

Which doesn't work since

"purpose": [
    "debug-test"
    ],

Isn't in the default config.

Several requests

  1. Make it the default to always launch the debug console
  2. Make it clear in the docs (and in the hints in vscode) that internalConsoleOptions must be used with
"purpose": [
    "debug-test"
    ],
  1. Add a new debug configuration just for debugging tests and make it be
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Debug Tests",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "purpose": [
                "debug-test" // the main requirement
            ],
            "console": "integratedTerminal",
            "justMyCode": false, // not bothered about this value
            "internalConsoleOptions": "openOnSessionStart" // the main requirement
        }
    ]
}

Here is a diff compared to the existing one Python File Debug the currently active Python file
image

  1. Update the existing Python File Debug the currently active Python file config to include. This is somewhat controversial but although it's incorrect, purpose works both for tests and debug file and therefore there is no downside by doing this.
"purpose": [
    "debug-test"
    ],
  1. Maybe remove this constraint for
"purpose": [
    "debug-test"
    ],

Since I don't see how this is related to launching the Debug console.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: false
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.2.1924087327
VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:55.248Z)
OS version: Windows_NT x64 10.0.19044
Restricted Mode: No
Remote OS version: Linux x64 5.10.60.1-microsoft-standard-WSL2

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 x 3193)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 7.95GB (1.57GB free)
Process Argv --crash-reporter-id 59055d64-30be-409f-a026-85b5df56f021
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.10.60.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 x 3192)
Memory (System) 6.16GB (5.45GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes516:30244333
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30451275
dsvsc009:30452663
pythonvsnew555:30457759
vscscmwlcmc:30438804
vscgsvidc:30447482
pynewfile477:30450038

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 27, 2022
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Mar 28, 2022
@karthiknadig
Copy link
Member

karthiknadig commented Mar 29, 2022

@1Mark the purpose field has nothing to do with console. It is only used by the extension to find the right debug configuration to use from the launch.json. If every configuration had debug-test set be default on it, then when user debugs a test, we would not know which one to pick. The only constraint that is there on debug-test is that it is used specifically when debugging tests using the Test view, there are no other constraints on it.

Make it the default to always launch the debug console

By default, the console option is set to integratedTerminal (not by the extension, this is the default for debug configurations). If console type is set to intergratedTerminal, we set the internalConsoleOptions to neverOpen. This is because historically, people have expected the focus to move to the terminal where the user code is executed.

Make it clear in the docs (and in the hints in vscode) that internalConsoleOptions must be used with

The neverOpen value is used due to how users expected the focus to move when debugging. We can change that but will require input from the community.

Add a new debug configuration just for debugging tests and make it be

This is something that we could do, but this would be a separate feature request. see here microsoft/vscode-python#11932

Update the existing Python File Debug the currently active Python file config to include. This is somewhat controversial but although it's incorrect, purpose works both for tests and debug file and therefore there is no downside by doing this.

Adding purpose to every configuration means, we don't know which configuration to use with debugging tests or some other thing. The intent of that field was to allow users to mark certain single configuration that we could use when we run tests using the Tests view. It is no-op when used in other cases. But, if it is added to all configuration, we are back to a situation where we don't know which configuration to use with tests.

Maybe remove this constraint for purpose

As mentioned before there is no constraint on that field that translates to restrictions on internalConsoleOptions.

/cc @luabud

@karthiknadig karthiknadig added the info-needed Issue requires more information from poster label Mar 29, 2022
@1Mark
Copy link
Author

1Mark commented Mar 29, 2022

@karthiknadig Ok I don't know if I'm missing the point but I've read it twice. My issue is that the following launch.json doesn't cause the debug console in vscode to open and be focused if I've closed it manually regardless of what I debug

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

The only way I got it to work was to add

purpose": [
    "debug-test"
    ],

This seems like a bug

@karthiknadig
Copy link
Member

@1Mark Oh I see. thanks for clarifying.

@brettcannon brettcannon removed the info-needed Issue requires more information from poster label Apr 28, 2022
@karthiknadig karthiknadig added the triage-needed Needs assignment to the proper sub-team label May 4, 2022
@paulacamargo25 paulacamargo25 added needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Sep 1, 2022
@dzid26
Copy link

dzid26 commented May 12, 2023

For me "internalConsoleOptions": "openOnSessionStart" causes the console to open, but VERY briefly. Something like 40ms. Then immediately goes back to the terminal.
I am on Win11.

It also affects another extension (Platformio IDE) which opens debug console using "internalConsoleOptions" "openOnSessionStart". And if I disable Python extension or if Python extension is not running yet, Platformio's original Debug Console behavior is fine.

@eleanorjboyd
Copy link
Member

Hi! This issue has been around a bit and we have made changes to this area in the meantime. Wanted to check in on if this is this still a problem you are facing. Thanks!

@eleanorjboyd eleanorjboyd added the info-needed Issue requires more information from poster label Dec 12, 2024
@eleanorjboyd
Copy link
Member

Hi! Are you still facing this bug?

@eleanorjboyd eleanorjboyd transferred this issue from microsoft/vscode-python Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

6 participants