Repository navigation
Activate in Python workspaces without an open Python file - #1155
Open
Dustin Zander (DatenpflegeNordHL) wants to merge 1 commit into
Open
Dustin Zander (DatenpflegeNordHL) wants to merge 1 commit into
Dustin Zander (DatenpflegeNordHL) wants to merge 1 commit into
Conversation
The launch.json completion item for Python Debugger is registered on activation, so "Add Configuration..." did not list it until a Python file was opened. Activate on the same root-level workspace markers that the Python extension uses (without the pylock glob, to avoid a workspace-wide file search). Fixes microsoft#203
Author
|
@microsoft-github-policy-service agree company="Green Vector Energo GmbH" |
Rich Chiodo (rchiodo)
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #203
The "Python Debugger" item in launch.json ("Add Configuration...") comes from the completion provider that is registered on activation, and the debugger currently only activates for debug events and
onLanguage:python. So in a workspace where no Python file has been opened yet, the item is missing.This adds
workspaceContainsactivation events for the root-level markers the Python extension uses (pyproject.toml,requirements.txt,setup.py,Pipfile,pylock.toml,manage.py,app.py,mspythonconfig.json,.venv,.conda). I left out the**/pylock.*.tomlglob since glob markers trigger a workspace-wide file search.Note that activating earlier also runs the rest of
activate()in these workspaces, including the no-config debug setup that updates the terminal environment. The Python extension already activates on the same markers, so this should not be new for most users. Workspaces without any of these markers at the root still need a Python file to be opened. If you'd rather activate onworkspaceContains:.vscode/launch.jsoninstead, I can change it, but that would also activate the extension in non-Python projects.Tested: new unit test for the activation events; manually checked in VS Code 1.148 that with a
requirements.txtworkspace and no Python file open, "Python Debugger" is now offered in launch.json, and that a workspace without markers is unchanged.npm run lint,npm run format-check,npm run compile-testsand the unit tests pass.