reset latest config preset after a validation/expansion error is corrected

This commit is contained in:
Fatima Qarni 2024-07-30 19:09:05 -07:00
Родитель 01fb95a04c
Коммит 4a774ad3e3
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -216,6 +216,16 @@ export class PresetsController {
if (this.project.configurePreset) {
await this.setConfigurePreset(this.project.configurePreset.name);
} else {
const latestConfigPresetName = this.project.workspaceContext.state.getLatestConfigurePresetName(this.folderName, this.project.isMultiProjectFolder);
if (latestConfigPresetName) {
// Check if the latest configurePresetName from the before the last preset change is still valid.
const presets = await this.getAllConfigurePresets();
const latestConfigPreset: preset.ConfigurePreset | undefined = presets.find(preset => preset.name === latestConfigPresetName);
if (latestConfigPreset && !latestConfigPreset.hidden) {
await this.setConfigurePreset(latestConfigPresetName);
}
}
}
// Don't need to set build/test presets here since they are reapplied in setConfigurePreset
}

Просмотреть файл

@ -40,7 +40,14 @@ export class StateManager {
return this._get<string>('configurePresetName', folderName, isMultiProject) || null;
}
getLatestConfigurePresetName(folderName: string, isMultiProject: boolean): string | null {
return this._get<string>('latest configurePreset', folderName, isMultiProject) || null;
}
async setConfigurePresetName(folderName: string, v: string | null, isMultiProject: boolean) {
if (v !== null) {
await this._update(`latest configurePreset`, v, folderName, isMultiProject);
}
await this._update('configurePresetName', v, folderName, isMultiProject);
}