Draft
Conversation
Contributor
|
@copilot try again |
Copilot stopped work on behalf of
hanniavalera due to an error
February 9, 2026 17:01
Copilot stopped work on behalf of
hanniavalera due to an error
February 9, 2026 17:06
Contributor
|
@copilot try again |
Contributor
Author
Fixed in The fix extracts workspace folder resolution into a
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Fix bug where workspace tasks cannot be run
Fix bug where workspace tasks cannot be run
Feb 9, 2026
When a cmake task is defined in a .code-workspace file, task.scope is TaskScope.Workspace (a number), not a WorkspaceFolder object. The previous code blindly cast task.scope to WorkspaceFolder, causing a crash when accessing workspaceFolder.uri.path. Extract workspace folder resolution into a shared helper method that: 1. Uses the task scope directly if it's a WorkspaceFolder object 2. Falls back to the active project's workspace folder 3. Falls back to the first available workspace folder Fixes #4529 Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
f5b3918 to
076a55b
Compare
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.
This change addresses item #4529
This changes visible behavior
The following changes are proposed:
getWorkspaceFolderFromTask()static helper method inCMakeTaskProvidertask.scopeis aWorkspaceFolderobject (viatypeofcheck) before using itWorkspaceFolder(e.g.,TaskScope.Workspacefor tasks defined in.code-workspacefiles), falls back to the active project's workspace folder, then to the first available workspace folderresolveTaskandresolveInternalTaskto use the new helperThe purpose of this change
When a CMake task is defined in a
.code-workspacefile, VS Code setstask.scopetoTaskScope.Workspace(the number2), not aWorkspaceFolderobject. The previous code blindly casttask.scopetoWorkspaceFolder, which meant thatworkspaceFolder.uriwasundefined, causing a crash withTypeError: Cannot read properties of undefined (reading 'path')inCustomBuildTaskTerminal.getProject(). This left the task stuck in a "Task is running" state.The fix ensures that when
task.scopeis not aWorkspaceFolderobject, the extension gracefully resolves the workspace folder from the active project or the first available workspace folder, allowing tasks defined in.code-workspacefiles to run correctly.Other Notes/Information
Repro steps:
.code-workspacefile with a CMake task definition (type: "cmake")TypeErrorin the ExtensionHost outputTasks defined in
tasks.jsonwere unaffected because VS Code provides a properWorkspaceFolderobject as the task scope in that case.Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug] Task defined inside workspace file can not be run, it is stuck in "Task is running" state.</issue_title>
<issue_description>### Brief Issue Summary
If the task is defined in workspace file, it is stuck with error:
Seems the problem with workspaceFolder.uri. The task example:
<...>.code-workspace:
If the task is replaced into tasks.json, the workspace folder is recognized and everything works correctly
CMake Tools Diagnostics
{ "os": "win32", "vscodeVersion": "1.95.3", "cmtVersion": "1.22.2", "configurations": [ { "folder": "<>", "cmakeVersion": "3.26.4", "configured": true, "generator": "Ninja", "usesPresets": false, "compilers": {} } ], "cpptoolsIntegration": { "isReady": true, "hasCodeModel": true, "activeBuildType": "Debug", "buildTypesSeen": [ "Debug" ], "requests": [], "responses": [], "partialMatches": [], "targetCount": 1, "executablesCount": 1, "librariesCount": 0, "targets": [ { "name": "main", "type": "EXECUTABLE" } ] }, "settings": [ { "communicationMode": "automatic", "useCMakePresets": "auto", "configureOnOpen": true } ] }Debug Log
Additional Information
No response</issue_description>
<agent_instructions>You are Copilot coding agent acting as a senior maintainer/contributor for the VS Code extension repository microsoft/vscode-cmake-tools.
You are deeply familiar with CMake, CMake Presets, CTest, kit/toolchain selection, VS Code extension APIs, and the architecture of this repo (TypeScript-heavy).
Your job is to resolve the GitHub issue provided below safely and in a maintainable way, matching existing patterns and UX.
SOURCE OF TRUTH
[Bug] Task defined inside workspace file can not be run, it is stuck in "Task is running" state. #4529 - Bug [Bug] Task defined inside workspace file can not be run, it is stuck in "Task is running" state. #4529
NON-NEGOTIABLE PROCESS
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.