Add configurable cwd setting to extension template#260
Merged
Conversation
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hardcoded working directory in extension template
Add configurable Feb 26, 2026
cwd setting to extension template
edvilme
reviewed
Feb 26, 2026
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Contributor
heejaechang
approved these changes
Feb 26, 2026
rchiodo
reviewed
Feb 26, 2026
|
|
||
| Examples of supported patterns: ``${fileDirname}``, ``${fileDirname}/subdir``. | ||
| """ | ||
| cwd = settings.get("cwd", settings["workspaceFS"]) |
There was a problem hiding this comment.
There are a lot more patterns than this. See this for the full list:
https://code.visualstudio.com/docs/reference/variables-reference
This was referenced Feb 26, 2026
github-actions bot
pushed a commit
to microsoft/vscode-isort
that referenced
this pull request
Feb 27, 2026
…substitution Syncs changes from microsoft/vscode-python-tools-extension-template#260 and #262. - Add isort.cwd configuration property to package.json (default: ${workspaceFolder}) - Add getCwd() usage in settings.ts getWorkspaceSettings() and checkIfConfigurationChanged() - Expand get_cwd() in lsp_server.py to support additional VS Code file-related variables: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder} - Add test_get_cwd.py with 17 unit tests covering all variable substitutions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
to microsoft/vscode-mypy
that referenced
this pull request
Feb 27, 2026
Applies changes from: - microsoft/vscode-python-tools-extension-template#262 (get_cwd variable substitution) - microsoft/vscode-python-tools-extension-template#260 (cwd setting - lsp_server.py portion) Updates get_cwd() in bundled/tool/lsp_server.py to support all VS Code file-related variable substitutions: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder}. Replaces the previous equality-based checks with substring replacement, allowing variables to be embedded inside longer paths (e.g. ${fileDirname}/subdir). Preserves the mypy-specific ${nearestConfig} behaviour. Fixes the dmypy (no-document) path to correctly return a plain cwd value rather than always falling back to workspaceFS. Adds src/test/python_tests/test_get_cwd.py with unit tests covering all variables, composite patterns, no-document fallbacks, and the mypy-specific ${nearestConfig} option. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
to microsoft/vscode-flake8
that referenced
this pull request
Feb 27, 2026
Applies changes from upstream template PRs: - microsoft/vscode-python-tools-extension-template#260 (cwd setting - already applied) - microsoft/vscode-python-tools-extension-template#262 (get_cwd variable substitution) Expands get_cwd() to resolve nine VS Code file-related variables: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder}. Adds 17 unit tests covering every variable, composite patterns, multi-variable strings, and no-document fallback behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
to microsoft/vscode-pylint
that referenced
this pull request
Feb 27, 2026
Sync changes from upstream template PRs: - microsoft/vscode-python-tools-extension-template#260 (Add configurable cwd setting) - microsoft/vscode-python-tools-extension-template#262 (get_cwd() variable substitution) Expands get_cwd() to support 9 VS Code file-related variable substitutions: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder}. Also adds unit tests for get_cwd() helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
to microsoft/vscode-black-formatter
that referenced
this pull request
Feb 27, 2026
…ution
- Add `${namespace}.cwd` to checkIfConfigurationChanged in settings.ts
(from microsoft/vscode-python-tools-extension-template#260)
- Update get_cwd() in lsp_server.py to support full VS Code variable
substitution (9 file-related variables) instead of exact-match only
(from microsoft/vscode-python-tools-extension-template#262)
- Add unit tests for get_cwd() helper (test_get_cwd.py)
(from microsoft/vscode-python-tools-extension-template#262)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
to microsoft/vscode-isort
that referenced
this pull request
Feb 27, 2026
…le substitution Syncs changes from: - microsoft/vscode-python-tools-extension-template#260 (Add configurable cwd setting) - microsoft/vscode-python-tools-extension-template#262 (get_cwd() variable substitution) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
edvilme
added a commit
to microsoft/vscode-isort
that referenced
this pull request
Feb 27, 2026
#543) * Sync with template: Add configurable cwd setting and expand variable substitution Syncs changes from microsoft/vscode-python-tools-extension-template#260 and #262. - Add isort.cwd configuration property to package.json (default: ${workspaceFolder}) - Add getCwd() usage in settings.ts getWorkspaceSettings() and checkIfConfigurationChanged() - Expand get_cwd() in lsp_server.py to support additional VS Code file-related variables: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder} - Add test_get_cwd.py with 17 unit tests covering all variable substitutions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Simplify test_get_cwd.py to match vscode-mypy PR #444 style (#544) * Initial plan * Initial plan Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> * Fix failing settings tests, clean up test_get_cwd.py, add cwd translations Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> * Add tests for each cwd variable substitution in settings.unit.test.ts Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> * Simplify test_get_cwd.py to match mypy PR #444 style; revert extra TS tests Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> * Lint --------- Co-authored-by: GitHub Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
edvilme
added a commit
to microsoft/vscode-mypy
that referenced
this pull request
Feb 27, 2026
* Sync get_cwd() variable substitution from template Applies changes from: - microsoft/vscode-python-tools-extension-template#262 (get_cwd variable substitution) - microsoft/vscode-python-tools-extension-template#260 (cwd setting - lsp_server.py portion) Updates get_cwd() in bundled/tool/lsp_server.py to support all VS Code file-related variable substitutions: ${file}, ${fileBasename}, ${fileBasenameNoExtension}, ${fileExtname}, ${fileDirname}, ${fileDirnameBasename}, ${relativeFile}, ${relativeFileDirname}, ${fileWorkspaceFolder}. Replaces the previous equality-based checks with substring replacement, allowing variables to be embedded inside longer paths (e.g. ${fileDirname}/subdir). Preserves the mypy-specific ${nearestConfig} behaviour. Fixes the dmypy (no-document) path to correctly return a plain cwd value rather than always falling back to workspaceFS. Adds src/test/python_tests/test_get_cwd.py with unit tests covering all variables, composite patterns, no-document fallbacks, and the mypy-specific ${nearestConfig} option. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix _MockLS stub missing window_log_message and LogMessageParams in test_get_cwd.py (#445) * Initial plan * Fix _MockLS missing window_log_message and LogMessageParams kwargs in test_get_cwd.py Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> * Fix linting issues in test_get_cwd.py (flake8 E302, black formatting) Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com> --------- Co-authored-by: GitHub Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.
src/common/settings.ts: AddedgetCwdhelper; replaced hardcodedcwd; addedcwdto watched settingspackage.json: Added<pytool-module>.cwdsettingbundled/tool/lsp_server.py: Addedget_cwd(); updated_run_tool_on_documentand_run_toolget_cwddocstring: removed misleading${workspaceFolder}mention (it's pre-resolved by TypeScript, not Python)get_cwdcall site explaining whydocumentis passedOriginal prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.