Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Improvements:
- Resolve diagnostics files relative to workspace and build directory, fixes [#1401](https://github.com/microsoft/vscode-cmake-tools/issues/1401) [@fargies](https://github.com/fargies)
- Add setting to only show the cmake log on target failure. [#3785](https://github.com/microsoft/vscode-cmake-tools/pull/3785) [@stepeos](https://github.com/stepeos)
- Preset expansion occurs on `CMakePresets.json` or `CMakeUserPresets.json` save, and if there are no errors the expanded presets are cached. The VS Developer Environment will only be applied to a preset if it is selected. Expansion errors will show in the problems panel and preset files with errors will be invalid, and any presets they contain cannot be used. [#3905](https://github.com/microsoft/vscode-cmake-tools/pull/3905)
- Remove pop-ups asking to configure, default `cmake.configureOnOpen` to `true`. [#3967](https://github.com/microsoft/vscode-cmake-tools/pull/3967)

Bug Fixes:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,7 @@
},
"cmake.configureOnOpen": {
"type": "boolean",
"default": null,
"default": true,
"description": "%cmake-tools.configuration.cmake.configureOnOpen.description%",
"scope": "resource",
"tags": [
Expand Down
4 changes: 2 additions & 2 deletions src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface DiagnosticsConfiguration {
export interface DiagnosticsSettings {
communicationMode: CMakeCommunicationMode;
useCMakePresets: UseCMakePresets;
configureOnOpen: boolean | null;
configureOnOpen: boolean;
}

export interface ConfigureCancelInformation {
Expand Down Expand Up @@ -3314,7 +3314,7 @@ export class CMakeProject {
return {
communicationMode: 'automatic',
useCMakePresets: 'auto',
configureOnOpen: null
configureOnOpen: true
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export interface ExtensionConfigurationSettings {
mergedCompileCommands: string | null;
copyCompileCommands: string | null;
loadCompileCommands: boolean;
configureOnOpen: boolean | null;
configureOnOpen: boolean;
configureOnEdit: boolean;
deleteBuildDirOnCleanConfigure: boolean;
skipConfigureIfCachePresent: boolean | null;
Expand Down Expand Up @@ -430,7 +430,7 @@ export class ConfigurationReader implements vscode.Disposable {
return this.configData.cpackArgs;
}
get configureOnOpen() {
if (util.isCodespaces() && this.configData.configureOnOpen === null) {
if (this.configData.configureOnOpen === null) {
return true;
}
return this.configData.configureOnOpen;
Expand Down Expand Up @@ -602,7 +602,7 @@ export class ConfigurationReader implements vscode.Disposable {
mergedCompileCommands: new vscode.EventEmitter<string | null>(),
copyCompileCommands: new vscode.EventEmitter<string | null>(),
loadCompileCommands: new vscode.EventEmitter<boolean>(),
configureOnOpen: new vscode.EventEmitter<boolean | null>(),
configureOnOpen: new vscode.EventEmitter<boolean>(),
configureOnEdit: new vscode.EventEmitter<boolean>(),
deleteBuildDirOnCleanConfigure: new vscode.EventEmitter<boolean>(),
skipConfigureIfCachePresent: new vscode.EventEmitter<boolean | null>(),
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/cmakeFileApiDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class CMakeFileApiDriver extends CMakeDriver {
if (cacheExists && this.generator?.name === await this.getGeneratorFromCache(this.cachePath)) {
await this.loadGeneratorInformationFromCache(this.cachePath);
const code_model_exist = await this.updateCodeModel();
if (!code_model_exist && this.config.configureOnOpen === true) {
if (!code_model_exist && this.config.configureOnOpen) {
await this.doConfigure([], undefined, undefined);
}
} else {
Expand All @@ -136,7 +136,7 @@ export class CMakeFileApiDriver extends CMakeDriver {
// Since this setting will prevent configure anyway (until a configure command is invoked
// or build/test will trigger automatic configuring), there is no need to delete the cache now
// even if this is not a project configured from outside VSCode.
if (cacheExists && this.config.configureOnOpen !== false) {
if (cacheExists && this.config.configureOnOpen) {
// No need to remove the other CMake files for the generator change to work properly
log.info(localize('removing', 'Removing {0}', this.cachePath));
try {
Expand Down
53 changes: 3 additions & 50 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,62 +594,15 @@ export class ExtensionManager implements vscode.Disposable {
vscode.workspace.workspaceFolders[0] === rootFolder &&
await scanForKitsIfNeeded(project);

let shouldConfigure = project?.workspaceContext.config.configureOnOpen;
const shouldConfigure = project?.workspaceContext.config.configureOnOpen;

const hascmakelists = await util.globForFileName("CMakeLists.txt", 3, project.folderPath);
if (shouldConfigure === null && !util.isTestMode() && hascmakelists) {
interface Choice1 {
title: string;
doConfigure: boolean;
}
const chosen = await vscode.window.showInformationMessage<Choice1>(
localize('configure.this.project', 'Would you like to configure project {0}?', `"${rootFolder.name}"`),
{},
{ title: localize('yes.button', 'Yes'), doConfigure: true },
{ title: localize('not.now.button', 'Not now'), doConfigure: false }
);
if (!chosen) {
// User cancelled.
shouldConfigure = null;
} else {
const persistMessage = chosen.doConfigure ?
localize('always.configure.on.open', 'Always configure projects upon opening?') :
localize('never.configure.on.open', 'Configure projects on opening?');
const buttonMessages = chosen.doConfigure ?
[localize('yes.button', 'Yes'), localize('no.button', 'No')] :
[localize('never.button', 'Never'), localize('never.for.this.workspace.button', 'Not this workspace')];
interface Choice2 {
title: string;
persistMode: 'user' | 'workspace';
}
// Try to persist the user's selection to a `settings.json`
const prompt = vscode.window.showInformationMessage<Choice2>(
persistMessage,
{},
{ title: buttonMessages[0], persistMode: 'user' },
{ title: buttonMessages[1], persistMode: 'workspace' })
.then(async choice => {
if (!choice) {
// Use cancelled. Do nothing.
return;
}
const config = vscode.workspace.getConfiguration(undefined, rootFolder.uri);
let configTarget = vscode.ConfigurationTarget.Global;
if (choice.persistMode === 'workspace') {
configTarget = vscode.ConfigurationTarget.WorkspaceFolder;
}
await config.update('cmake.configureOnOpen', chosen.doConfigure, configTarget);
});
rollbar.takePromise(localize('persist.config.on.open.setting', 'Persist config-on-open setting'), {}, prompt);
shouldConfigure = chosen.doConfigure;
}
}
if (!project.hasCMakeLists()) {
if (shouldConfigure === true && hascmakelists) {
if (shouldConfigure && hascmakelists) {
await project.cmakePreConditionProblemHandler(CMakePreconditionProblems.MissingCMakeListsFile, false, this.workspaceConfig);
}
} else {
if (shouldConfigure === true) {
if (shouldConfigure) {
// We've opened a new workspace folder, and the user wants us to
// configure it now.
log.debug(localize('configuring.workspace.on.open', 'Configuring workspace on open {0}', project.folderPath));
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function createConfig(conf: Partial<ExtensionConfigurationSettings>): Configurat
mergedCompileCommands: null,
copyCompileCommands: null,
loadCompileCommands: true,
configureOnOpen: null,
configureOnOpen: true,
configureOnEdit: true,
deleteBuildDirOnCleanConfigure: false,
skipConfigureIfCachePresent: null,
Expand Down