Skip to content

Commit

Permalink
add option to disable asking if we should still build when not all do… (
Browse files Browse the repository at this point in the history
#3527)

* add option to disable asking if we should still build when not all documents are saved

* changelog

---------

Co-authored-by: snehara99 <[email protected]>
  • Loading branch information
gcampbell-msft and snehara99 authored Jan 18, 2024
1 parent 3516215 commit 566268f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Improvements:

- Improve when the "Configure with Debugger" popup appears and allow for "Do Not Show Again". [#3343](https://github.com/microsoft/vscode-cmake-tools/issues/3343)
- Add option to disable "Not all open documents were saved" popup. [#2889](https://github.com/microsoft/vscode-cmake-tools/issues/2889)

Bug Fixes:

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,12 @@
"description": "%cmake-tools.configuration.cmake.showConfigureWithDebuggerNotification%",
"scope": "application"
},
"cmake.showNotAllDocumentsSavedQuestion": {
"type": "boolean",
"default": true,
"description": "%cmake-tools.configuration.cmake.showNotAllDocumentsSavedQuestion%",
"scope": "application"
},
"cmake.options.statusBarVisibility": {
"type": "string",
"default": "hidden",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"cmake-tools.configuration.cmake.touchbar.visibility.hidden.description": "Do not show Touch Bar buttons.",
"cmake-tools.configuration.cmake.showOptionsMovedNotification": "Enables the notification regarding the status bar options moving to the Project Status View to show when the extension starts.",
"cmake-tools.configuration.cmake.showConfigureWithDebuggerNotification": "Enables the pop-up that asks the user if, upon a failed configure, they want to configure with the CMake Debugger.",
"cmake-tools.configuration.cmake.showNotAllDocumentsSavedQuestion": "Enables the pop-up that asks the user if they want to continue the build despite some files possibly not being saved. If not enabled, the build will be continued.",
"cmake-tools.configuration.cmake.options.advanced.statusBarVisibility.visible.description": "Show the status bar option at full size.",
"cmake-tools.configuration.cmake.options.advanced.statusBarVisibility.icon.description": "Show the status bar option's icon only.",
"cmake-tools.configuration.cmake.options.advanced.statusBarVisibility.compact.markdownDescription": "Show the status bar option with the text truncated to the length specified in `#cmake.status.advanced.statusBarLength#` (default is 20).",
Expand Down
41 changes: 29 additions & 12 deletions src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1486,21 +1486,38 @@ export class CMakeProject {
log.debug(localize('saving.open.files.before', 'Saving open files before configure/build'));
}

const cmakeConfiguration = vscode.workspace.getConfiguration('cmake');
const showSaveFailedNotificationString = "showNotAllDocumentsSavedQuestion";

const saveGood = await vscode.workspace.saveAll();
if (!saveGood) {
if (!saveGood && cmakeConfiguration.get(showSaveFailedNotificationString)) {
log.debug(localize('saving.open.files.failed', 'Saving open files failed'));
const yesButtonTitle: string = localize('yes.button', 'Yes');
const chosen = await vscode.window.showErrorMessage<vscode.MessageItem>(
localize('not.saved.continue.anyway', 'Not all open documents were saved. Would you like to continue anyway?'),
{
title: yesButtonTitle,
isCloseAffordance: false
},
{
title: localize('no.button', 'No'),
isCloseAffordance: true
});
return chosen !== undefined && (chosen.title === yesButtonTitle);
const yesAndDoNotShowAgain: string = localize('do.not.show.not.saved.again', "Yes (don't show again)");
const chosen =
await vscode.window.showErrorMessage<vscode.MessageItem>(
localize(
"not.saved.continue.anyway",
"Not all open documents were saved. Would you like to continue anyway?"
),
{
title: yesButtonTitle,
isCloseAffordance: false
},
{
title: yesAndDoNotShowAgain,
isCloseAffordance: false
},
{
title: localize("no.button", "No"),
isCloseAffordance: true
}
);

if (chosen?.title === yesAndDoNotShowAgain) {
await cmakeConfiguration.update(showSaveFailedNotificationString, false, vscode.ConfigurationTarget.Global);
}
return chosen !== undefined && (chosen.title === yesButtonTitle || chosen.title === yesAndDoNotShowAgain);
}
}
return true;
Expand Down

0 comments on commit 566268f

Please sign in to comment.