Skip to content

Activate in Python workspaces without an open Python file - #1155

Open
Dustin Zander (DatenpflegeNordHL) wants to merge 1 commit into
microsoft:mainfrom
DatenpflegeNordHL:add-workspace-activation-events
Open

Dustin Zander (DatenpflegeNordHL) wants to merge 1 commit into
microsoft:mainfrom
DatenpflegeNordHL:add-workspace-activation-events

Conversation

@DatenpflegeNordHL

Copy link
Copy Markdown

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 workspaceContains activation 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.*.toml glob 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 on workspaceContains:.vscode/launch.json instead, 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.txt workspace 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-tests and the unit tests pass.

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
@DatenpflegeNordHL

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Green Vector Energo GmbH"

@rchiodo Rich Chiodo (rchiodo) added the bug Issue identified by VS Code Team member as probable bug label Nov 25, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add more activation events for the python debugger extension

2 participants