Skip to content

Commit c229ed4

Browse files
Copilotsnehara99
andauthored
Fix quickStart silent failure when no folder is open (#4695)
* Initial plan * Fix quickStart silent failure when no folder is open Co-authored-by: snehara99 <[email protected]> * Make quickStart error message more descriptive Co-authored-by: snehara99 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: snehara99 <[email protected]>
1 parent a462db4 commit c229ed4

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Features:
88

99
Bug Fixes:
1010

11+
- Fix "CMake: Quick Start" command failing silently when no folder is open. Now shows an error message with an option to open a folder. [#4504](https://github.com/microsoft/vscode-cmake-tools/issues/4504)
1112
- Fix "CMake: Run Without Debugging" not changing the working directory when the build directory changes. [#4549](https://github.com/microsoft/vscode-cmake-tools/issues/4549)
1213
- Fix CMake script path links not working in CHS/CSY/FRA/PLK locales due to localized quotes. [#4383](https://github.com/microsoft/vscode-cmake-tools/issues/4383)
1314
- Fix user-level tasks defined in `~/.config/Code/User/tasks.json` causing infinite spinner. [#4659](https://github.com/microsoft/vscode-cmake-tools/pull/4659)

src/extension.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,8 +1669,22 @@ export class ExtensionManager implements vscode.Disposable {
16691669
return this.runCMakeCommandForAll(cmakeProject => cmakeProject.stop());
16701670
}
16711671

1672-
quickStart(folder?: vscode.WorkspaceFolder) {
1672+
async quickStart(folder?: vscode.WorkspaceFolder) {
16731673
telemetry.logEvent("quickStart");
1674+
1675+
// Check if there are no workspace folders open
1676+
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
1677+
const openFolder = localize('open.folder', 'Open Folder');
1678+
const result = await vscode.window.showErrorMessage(
1679+
localize('no.folder.open.for.quickstart', 'No folder is open. Please open a folder to use CMake: Quick Start.'),
1680+
openFolder
1681+
);
1682+
if (result === openFolder) {
1683+
await vscode.commands.executeCommand('vscode.openFolder');
1684+
}
1685+
return -2;
1686+
}
1687+
16741688
return this.runCMakeCommandForProject(cmakeProject => cmakeProject.quickStart(folder));
16751689
}
16761690

0 commit comments

Comments
 (0)