Merge branch 'elrashed/addStatForMultiPr' into elrashed/sideBarState
This commit is contained in:
Коммит
d5d16711d3
|
@ -215,10 +215,10 @@ export class CMakeProject {
|
|||
private readonly _configurePreset = new Property<preset.ConfigurePreset | null>(null);
|
||||
|
||||
private async resetPresets() {
|
||||
await this.workspaceContext.state.setConfigurePresetName(null);
|
||||
await this.workspaceContext.state.setConfigurePresetName(this.folderName, null);
|
||||
if (this.configurePreset) {
|
||||
await this.workspaceContext.state.setBuildPresetName(this.configurePreset.name, null);
|
||||
await this.workspaceContext.state.setTestPresetName(this.configurePreset.name, null);
|
||||
await this.workspaceContext.state.setBuildPresetName(this.folderName, this.configurePreset.name, null);
|
||||
await this.workspaceContext.state.setTestPresetName(this.folderName, this.configurePreset.name, null);
|
||||
}
|
||||
this._configurePreset.set(null);
|
||||
this._buildPreset.set(null);
|
||||
|
@ -275,7 +275,7 @@ export class CMakeProject {
|
|||
try {
|
||||
this.statusMessage.set(localize('reloading.status', 'Reloading...'));
|
||||
await drv.setConfigurePreset(expandedConfigurePreset);
|
||||
await this.workspaceContext.state.setConfigurePresetName(configurePreset);
|
||||
await this.workspaceContext.state.setConfigurePresetName(this.folderName, configurePreset);
|
||||
this.statusMessage.set(localize('ready.status', 'Ready'));
|
||||
} catch (error: any) {
|
||||
void vscode.window.showErrorMessage(localize('unable.to.set.config.preset', 'Unable to set configure preset {0}.', `"${error}"`));
|
||||
|
@ -285,7 +285,7 @@ export class CMakeProject {
|
|||
}
|
||||
} else {
|
||||
// Remember the selected configure preset for the next session.
|
||||
await this.workspaceContext.state.setConfigurePresetName(configurePreset);
|
||||
await this.workspaceContext.state.setConfigurePresetName(this.folderName, configurePreset);
|
||||
}
|
||||
} else {
|
||||
await this.resetPresets();
|
||||
|
@ -345,7 +345,7 @@ export class CMakeProject {
|
|||
try {
|
||||
this.statusMessage.set(localize('reloading.status', 'Reloading...'));
|
||||
await drv.setBuildPreset(expandedBuildPreset);
|
||||
await this.workspaceContext.state.setBuildPresetName(expandedBuildPreset.configurePreset, buildPreset);
|
||||
await this.workspaceContext.state.setBuildPresetName(this.folderName, expandedBuildPreset.configurePreset, buildPreset);
|
||||
this.statusMessage.set(localize('ready.status', 'Ready'));
|
||||
} catch (error: any) {
|
||||
void vscode.window.showErrorMessage(localize('unable.to.set.build.preset', 'Unable to set build preset {0}.', `"${error}"`));
|
||||
|
@ -355,12 +355,12 @@ export class CMakeProject {
|
|||
}
|
||||
} else {
|
||||
// Remember the selected build preset for the next session.
|
||||
await this.workspaceContext.state.setBuildPresetName(expandedBuildPreset.configurePreset, buildPreset);
|
||||
await this.workspaceContext.state.setBuildPresetName(this.folderName, expandedBuildPreset.configurePreset, buildPreset);
|
||||
}
|
||||
} else {
|
||||
this._buildPreset.set(null);
|
||||
if (this.configurePreset) {
|
||||
await this.workspaceContext.state.setBuildPresetName(this.configurePreset.name, null);
|
||||
await this.workspaceContext.state.setBuildPresetName(this.folderName, this.configurePreset.name, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ export class CMakeProject {
|
|||
this.statusMessage.set(localize('reloading.status', 'Reloading...'));
|
||||
await drv.setTestPreset(expandedTestPreset);
|
||||
if (expandedTestPreset.configurePreset) {
|
||||
await this.workspaceContext.state.setTestPresetName(expandedTestPreset.configurePreset, testPreset);
|
||||
await this.workspaceContext.state.setTestPresetName(this.folderName, expandedTestPreset.configurePreset, testPreset);
|
||||
}
|
||||
this.statusMessage.set(localize('ready.status', 'Ready'));
|
||||
} catch (error: any) {
|
||||
|
@ -430,13 +430,13 @@ export class CMakeProject {
|
|||
} else {
|
||||
if (expandedTestPreset.configurePreset) {
|
||||
// Remember the selected test preset for the next session.
|
||||
await this.workspaceContext.state.setTestPresetName(expandedTestPreset.configurePreset, testPreset);
|
||||
await this.workspaceContext.state.setTestPresetName(this.folderName, expandedTestPreset.configurePreset, testPreset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._testPreset.set(null);
|
||||
if (this.configurePreset) {
|
||||
await this.workspaceContext.state.setTestPresetName(this.configurePreset.name, null);
|
||||
await this.workspaceContext.state.setTestPresetName(this.folderName, this.configurePreset.name, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +642,7 @@ export class CMakeProject {
|
|||
|
||||
telemetry.logEvent('missingCMakeListsFile'); // Fire this event in case the notification is dismissed with the `ESC` key.
|
||||
|
||||
const ignoreCMakeListsMissing: boolean = this.workspaceContext.state.ignoreCMakeListsMissing || this.workspaceContext.config.ignoreCMakeListsMissing;
|
||||
const ignoreCMakeListsMissing: boolean = this.workspaceContext.state.getIgnoreCMakeListsMissing(this.folderName) || this.workspaceContext.config.ignoreCMakeListsMissing;
|
||||
telemetryProperties["ignoreCMakeListsMissing"] = ignoreCMakeListsMissing.toString();
|
||||
|
||||
if (!ignoreCMakeListsMissing && !this.isMultiProjectFolder) {
|
||||
|
@ -898,11 +898,11 @@ export class CMakeProject {
|
|||
this.hideLaunchButton = (this.workspaceContext.config.statusbar.advanced?.launch?.visibility === "hidden") ? true : false;
|
||||
|
||||
// Start up the variant manager
|
||||
await this.variantManager.initialize();
|
||||
await this.variantManager.initialize(this.folderName);
|
||||
// Set the status bar message
|
||||
this.activeVariant.set(this.variantManager.activeVariantOptions.short);
|
||||
// Restore the debug target
|
||||
this._launchTargetName.set(this.workspaceContext.state.launchTargetName || '');
|
||||
this._launchTargetName.set(this.workspaceContext.state.getLaunchTargetName(this.folderName) || '');
|
||||
|
||||
// Hook up event handlers
|
||||
// Listen for the variant to change
|
||||
|
@ -994,7 +994,7 @@ export class CMakeProject {
|
|||
|
||||
async initializeKitOrPresets() {
|
||||
if (this.useCMakePresets) {
|
||||
const latestConfigPresetName = this.workspaceContext.state.configurePresetName;
|
||||
const latestConfigPresetName = this.workspaceContext.state.getConfigurePresetName(this.folderName);
|
||||
if (latestConfigPresetName) {
|
||||
// Check if the latest configurePresetName from the previous session is still valid.
|
||||
const presets = await this.presetsController.getAllConfigurePresets();
|
||||
|
@ -1005,7 +1005,7 @@ export class CMakeProject {
|
|||
}
|
||||
} else {
|
||||
// Check if the CMakeProject remembers what kit it was last using in this dir:
|
||||
const kitName = this.workspaceContext.state.activeKitName;
|
||||
const kitName = this.workspaceContext.state.getActiveKitName(this.folderName);
|
||||
if (kitName) {
|
||||
// It remembers a kit. Find it in the kits avail in this dir:
|
||||
const kit = this.kitsController.availableKits.find(k => k.name === kitName) || null;
|
||||
|
@ -1038,7 +1038,7 @@ export class CMakeProject {
|
|||
try {
|
||||
this.statusMessage.set(localize('reloading.status', 'Reloading...'));
|
||||
await drv.setKit(kit, this.getPreferredGenerators());
|
||||
await this.workspaceContext.state.setActiveKitName(kit.name);
|
||||
await this.workspaceContext.state.setActiveKitName(this.folderName, kit.name);
|
||||
this.statusMessage.set(localize('ready.status', 'Ready'));
|
||||
} catch (error: any) {
|
||||
void vscode.window.showErrorMessage(localize('unable.to.set.kit', 'Unable to set kit {0}.', `"${error.message}"`));
|
||||
|
@ -1048,7 +1048,7 @@ export class CMakeProject {
|
|||
}
|
||||
} else {
|
||||
// Remember the selected kit for the next session.
|
||||
await this.workspaceContext.state.setActiveKitName(kit.name);
|
||||
await this.workspaceContext.state.setActiveKitName(this.folderName, kit.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1902,10 +1902,10 @@ export class CMakeProject {
|
|||
* The target that will be built with a regular build invocation
|
||||
*/
|
||||
public get defaultBuildTarget(): string | null {
|
||||
return this.workspaceContext.state.defaultBuildTarget;
|
||||
return this.workspaceContext.state.getDefaultBuildTarget(this.folderName);
|
||||
}
|
||||
private async setDefaultBuildTarget(v: string) {
|
||||
await this.workspaceContext.state.setDefaultBuildTarget(v);
|
||||
await this.workspaceContext.state.setDefaultBuildTarget(this.folderName, v);
|
||||
this.targetName.set(v);
|
||||
}
|
||||
|
||||
|
@ -1967,7 +1967,7 @@ export class CMakeProject {
|
|||
return null;
|
||||
} if (executableTargets.length === 1) {
|
||||
const target = executableTargets[0];
|
||||
await this.workspaceContext.state.setLaunchTargetName(target.name);
|
||||
await this.workspaceContext.state.setLaunchTargetName(this.folderName, target.name);
|
||||
this._launchTargetName.set(target.name);
|
||||
return target.path;
|
||||
}
|
||||
|
@ -1986,13 +1986,13 @@ export class CMakeProject {
|
|||
if (!chosen) {
|
||||
return null;
|
||||
}
|
||||
await this.workspaceContext.state.setLaunchTargetName(chosen.label);
|
||||
await this.workspaceContext.state.setLaunchTargetName(this.folderName, chosen.label);
|
||||
this._launchTargetName.set(chosen.label);
|
||||
return chosen.detail;
|
||||
}
|
||||
|
||||
async getCurrentLaunchTarget(): Promise<ExecutableTarget | null> {
|
||||
const targetName = this.workspaceContext.state.launchTargetName;
|
||||
const targetName = this.workspaceContext.state.getLaunchTargetName(this.folderName);
|
||||
const target = (await this.executableTargets).find(e => e.name === targetName);
|
||||
|
||||
if (!target) {
|
||||
|
@ -2493,7 +2493,7 @@ export class CMakeProject {
|
|||
* Implementation of `cmake.resetState`
|
||||
*/
|
||||
async resetState() {
|
||||
await this.workspaceContext.state.reset();
|
||||
await this.workspaceContext.state.reset(this.folderName);
|
||||
}
|
||||
|
||||
// Don't get this from the driver. Source dir is required to evaluate presets.
|
||||
|
|
|
@ -681,8 +681,8 @@ export class PresetsController {
|
|||
},
|
||||
async () => {
|
||||
const configurePreset = this.project.configurePreset?.name;
|
||||
const buildPreset = configurePreset ? this.project.workspaceContext.state.getBuildPresetName(configurePreset) : undefined;
|
||||
const testPreset = configurePreset ? this.project.workspaceContext.state.getTestPresetName(configurePreset) : undefined;
|
||||
const buildPreset = configurePreset ? this.project.workspaceContext.state.getBuildPresetName(this.project.folderName, configurePreset) : undefined;
|
||||
const testPreset = configurePreset ? this.project.workspaceContext.state.getTestPresetName(this.project.folderName, configurePreset) : undefined;
|
||||
if (buildPreset) {
|
||||
await this.setBuildPreset(buildPreset, true/*needToCheckConfigurePreset*/, false/*checkChangingPreset*/);
|
||||
}
|
||||
|
|
155
src/state.ts
155
src/state.ts
|
@ -11,7 +11,7 @@ import * as vscode from 'vscode';
|
|||
* invalid states.
|
||||
*/
|
||||
export class StateManager {
|
||||
constructor(readonly extensionContext: vscode.ExtensionContext, readonly folder: vscode.WorkspaceFolder) {}
|
||||
constructor(readonly extensionContext: vscode.ExtensionContext, readonly folder: vscode.WorkspaceFolder, private isMultiProject: boolean = false) {}
|
||||
|
||||
private _get<T>(key: string): T | undefined {
|
||||
return this.extensionContext.globalState.get<T>(this.folder.uri.fsPath + key);
|
||||
|
@ -21,108 +21,147 @@ export class StateManager {
|
|||
return this.extensionContext.globalState.update(this.folder.uri.fsPath + key, value);
|
||||
}
|
||||
|
||||
setIsMultiProject(isMultiProject: boolean) {
|
||||
this.isMultiProject = isMultiProject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the user chose to ignore the popup message about missing CMakeLists.txt
|
||||
* from the root folder, for a code base that is not fully activating CMake Tools.
|
||||
*/
|
||||
get ignoreCMakeListsMissing(): boolean {
|
||||
return this._get<boolean>('ignoreCMakeListsMissing') || false;
|
||||
getIgnoreCMakeListsMissing(folderName: string): boolean {
|
||||
return this.isMultiProject ? (this._get<boolean>(`${folderName} ignoreCMakeListsMissing`) || false) :
|
||||
(this._get<boolean>('ignoreCMakeListsMissing') || false);
|
||||
}
|
||||
|
||||
async setIgnoreCMakeListsMissing(v: boolean) {
|
||||
await this._update('ignoreCMakeListsMissing', v);
|
||||
async setIgnoreCMakeListsMissing(folderName: string, v: boolean) {
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} ignoreCMakeListsMissing`, v);
|
||||
} else {
|
||||
await this._update('ignoreCMakeListsMissing', v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the workspace-local active configure preset
|
||||
*/
|
||||
get configurePresetName(): string | null {
|
||||
const preset = this._get<string>('configurePresetName');
|
||||
getConfigurePresetName(folderName: string): string | null {
|
||||
const preset = this.isMultiProject ? this._get<string>(`${folderName} configurePresetName`) : this._get<string>('configurePresetName');
|
||||
return preset || null;
|
||||
}
|
||||
|
||||
async setConfigurePresetName(v: string | null) {
|
||||
await this._update('configurePresetName', v);
|
||||
async setConfigurePresetName(folderName: string, v: string | null) {
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} configurePresetName`, v);
|
||||
} else {
|
||||
await this._update('configurePresetName', v);
|
||||
}
|
||||
}
|
||||
|
||||
private get cachedConfigurePresets(): string[] {
|
||||
return this._get<string[]>('cachedConfigurePresets') || [];
|
||||
private getCachedConfigurePresets(folderName: string): string[] {
|
||||
return this.isMultiProject ? (this._get<string[]>(`${folderName} cachedConfigurePresets`) || []) :
|
||||
(this._get<string[]>('cachedConfigurePresets') || []);
|
||||
}
|
||||
|
||||
private async addCachedConfigurePreset(preset: string) {
|
||||
const configurePresets = this.cachedConfigurePresets;
|
||||
private async addCachedConfigurePreset(folderName: string, preset: string) {
|
||||
const configurePresets = this.getCachedConfigurePresets(folderName);
|
||||
if (configurePresets.indexOf(preset) >= 0) {
|
||||
return;
|
||||
}
|
||||
configurePresets.push(preset);
|
||||
return this._update('cachedConfigurePresets', configurePresets);
|
||||
return this.isMultiProject ? this._update(`${folderName} cachedConfigurePresets`, configurePresets) :
|
||||
this._update('cachedConfigurePresets', configurePresets);
|
||||
}
|
||||
|
||||
private async clearCachedConfigurePresets() {
|
||||
const configurePresets = this.cachedConfigurePresets;
|
||||
private async clearCachedConfigurePresets(folderName: string) {
|
||||
const configurePresets = this.getCachedConfigurePresets(folderName);
|
||||
for (const preset of configurePresets) {
|
||||
await this.setBuildPresetName(preset, null);
|
||||
await this.setTestPresetName(preset, null);
|
||||
await this.setBuildPresetName(folderName, preset, null);
|
||||
await this.setTestPresetName(folderName, preset, null);
|
||||
}
|
||||
return this._update('cachedConfigurePresets', null);
|
||||
return this.isMultiProject ? this._update(`${folderName} cachedConfigurePresets`, null) :
|
||||
this._update('cachedConfigurePresets', null);
|
||||
}
|
||||
|
||||
getBuildPresetName(configurePreset: string): string | null {
|
||||
return this._get<string>(`buildPreset for ${configurePreset}`) || null;
|
||||
getBuildPresetName(folderName: string, configurePreset: string): string | null {
|
||||
return this.isMultiProject ? (this._get<string>(`${folderName} buildPreset for ${configurePreset}`) || null) :
|
||||
(this._get<string>(`buildPreset for ${configurePreset}`) || null);
|
||||
}
|
||||
|
||||
async setBuildPresetName(configurePreset: string, v: string | null) {
|
||||
await this.addCachedConfigurePreset(configurePreset);
|
||||
await this._update(`buildPreset for ${configurePreset}`, v);
|
||||
async setBuildPresetName(folderName: string, configurePreset: string, v: string | null) {
|
||||
await this.addCachedConfigurePreset(folderName, configurePreset);
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} buildPreset for ${configurePreset}`, v);
|
||||
} else {
|
||||
await this._update(`buildPreset for ${configurePreset}`, v);
|
||||
}
|
||||
}
|
||||
|
||||
getTestPresetName(configurePreset: string): string | null {
|
||||
return this._get<string>(`testPreset for ${configurePreset}`) || null;
|
||||
getTestPresetName(folderName: string, configurePreset: string): string | null {
|
||||
return this.isMultiProject ? (this._get<string>(`${folderName} testPreset for ${configurePreset}`) || null) :
|
||||
(this._get<string>(`testPreset for ${configurePreset}`) || null);
|
||||
}
|
||||
|
||||
async setTestPresetName(configurePreset: string, v: string | null) {
|
||||
await this.addCachedConfigurePreset(configurePreset);
|
||||
await this._update(`testPreset for ${configurePreset}`, v);
|
||||
async setTestPresetName(folderName: string, configurePreset: string, v: string | null) {
|
||||
await this.addCachedConfigurePreset(folderName, configurePreset);
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} testPreset for ${configurePreset}`, v);
|
||||
} else {
|
||||
await this._update(`testPreset for ${configurePreset}`, v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the workspace-local active kit.
|
||||
*/
|
||||
get activeKitName(): string | null {
|
||||
const kit = this._get<string>('activeKitName');
|
||||
getActiveKitName(folderName: string): string | null {
|
||||
const kit = this.isMultiProject ? this._get<string>(`${folderName} activeKitName`) : this._get<string>('activeKitName');
|
||||
return kit || null;
|
||||
}
|
||||
|
||||
async setActiveKitName(v: string | null) {
|
||||
await this._update('activeKitName', v);
|
||||
async setActiveKitName(folderName: string, v: string | null) {
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} activeKitName`, v);
|
||||
} else {
|
||||
await this._update('activeKitName', v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The currently select build target
|
||||
*/
|
||||
get defaultBuildTarget(): string | null {
|
||||
const target = this._get<string>('activeBuildTarget');
|
||||
getDefaultBuildTarget(folderName: string): string | null {
|
||||
const target = this.isMultiProject ? this._get<string>(`${folderName} activeBuildTarget`) : this._get<string>('activeBuildTarget');
|
||||
return target || null;
|
||||
}
|
||||
|
||||
async setDefaultBuildTarget(s: string | null) {
|
||||
await this._update('activeBuildTarget', s);
|
||||
async setDefaultBuildTarget(folderName: string, v: string | null) {
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} activeBuildTarget`, v);
|
||||
} else {
|
||||
await this._update('activeBuildTarget', v);
|
||||
}
|
||||
}
|
||||
|
||||
get launchTargetName(): string | null {
|
||||
const name = this._get<string>('launchTargetName');
|
||||
getLaunchTargetName(folderName: string): string | null {
|
||||
const name = this.isMultiProject ? this._get<string>(`${folderName} launchTargetName`) : this._get<string>('launchTargetName');
|
||||
return name || null;
|
||||
}
|
||||
|
||||
async setLaunchTargetName(t: string | null) {
|
||||
await this._update('launchTargetName', t);
|
||||
async setLaunchTargetName(folderName: string, t: string | null) {
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} launchTargetName`, t);
|
||||
} else {
|
||||
await this._update('launchTargetName', t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The keyword settings for the build variant
|
||||
*/
|
||||
get activeVariantSettings(): Map<string, string> | null {
|
||||
const pairs = this._get<[string, string][]>('activeVariantSettings');
|
||||
getActiveVariantSettings(folderName: string): Map<string, string> | null {
|
||||
const pairs = this.isMultiProject ? this._get<[string, string][]>(`${folderName} activeVariantSettings`) :
|
||||
this._get<[string, string][]>('activeVariantSettings');
|
||||
if (pairs) {
|
||||
return new Map<string, string>(pairs);
|
||||
} else {
|
||||
|
@ -130,25 +169,33 @@ export class StateManager {
|
|||
}
|
||||
}
|
||||
|
||||
async setActiveVariantSettings(settings: Map<string, string> | null) {
|
||||
async setActiveVariantSettings(folderName: string, settings: Map<string, string> | null) {
|
||||
if (settings) {
|
||||
const pairs: [string, string][] = Array.from(settings.entries());
|
||||
await this._update('activeVariantSettings', pairs);
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} activeVariantSettings`, pairs);
|
||||
} else {
|
||||
await this._update('activeVariantSettings', pairs);
|
||||
}
|
||||
} else {
|
||||
await this._update('activeVariantSettings', null);
|
||||
if (this.isMultiProject) {
|
||||
await this._update(`${folderName} activeVariantSettings`, null);
|
||||
} else {
|
||||
await this._update('activeVariantSettings', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rest all current workspace state. Mostly for troubleshooting
|
||||
*/
|
||||
async reset() {
|
||||
await this.setConfigurePresetName(null);
|
||||
await this.clearCachedConfigurePresets();
|
||||
await this.setActiveVariantSettings(null);
|
||||
await this.setLaunchTargetName(null);
|
||||
await this.setDefaultBuildTarget(null);
|
||||
await this.setActiveKitName(null);
|
||||
await this.setIgnoreCMakeListsMissing(false);
|
||||
async reset(folderName: string) {
|
||||
await this.setConfigurePresetName(folderName, null);
|
||||
await this.clearCachedConfigurePresets(folderName);
|
||||
await this.setActiveVariantSettings(folderName, null);
|
||||
await this.setLaunchTargetName(folderName, null);
|
||||
await this.setDefaultBuildTarget(folderName, null);
|
||||
await this.setActiveKitName(folderName, null);
|
||||
await this.setIgnoreCMakeListsMissing(folderName, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
}
|
||||
|
||||
get haveVariant(): boolean {
|
||||
return !!this.stateManager.activeVariantSettings;
|
||||
return !!this.stateManager.getActiveVariantSettings(this.folderName);
|
||||
}
|
||||
|
||||
variantConfigurationOptionsForKWs(keywordSetting: Map<string, string>): VariantOption[] | string {
|
||||
|
@ -331,7 +331,7 @@ export class VariantManager implements vscode.Disposable {
|
|||
short: 'Unknown',
|
||||
long: 'Unknwon'
|
||||
};
|
||||
const kws = this.stateManager.activeVariantSettings;
|
||||
const kws = this.stateManager.getActiveVariantSettings(this.folderName);
|
||||
if (!kws) {
|
||||
return invalid_variant;
|
||||
}
|
||||
|
@ -403,12 +403,12 @@ export class VariantManager implements vscode.Disposable {
|
|||
}
|
||||
|
||||
async publishActiveKeywordSettings(keywordSettings: Map<string, string>) {
|
||||
await this.stateManager.setActiveVariantSettings(keywordSettings);
|
||||
await this.stateManager.setActiveVariantSettings(this.folderName, keywordSettings);
|
||||
this._activeVariantChanged.fire();
|
||||
}
|
||||
|
||||
public get activeKeywordSetting(): Map<string, string> | null {
|
||||
return this.stateManager.activeVariantSettings;
|
||||
return this.stateManager.getActiveVariantSettings(this.folderName);
|
||||
}
|
||||
|
||||
transformChoiceCombinationToKeywordSettings(choiceCombination: { settingKey: string; settingValue: string }[]): Map<string, string> {
|
||||
|
@ -425,10 +425,11 @@ export class VariantManager implements vscode.Disposable {
|
|||
return this.transformChoiceCombinationToKeywordSettings(Array.from(defaults));
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
private folderName: string = "";
|
||||
async initialize(folderName: string) {
|
||||
await this._reloadVariantsFile();
|
||||
|
||||
if (this.stateManager.activeVariantSettings === null) {
|
||||
this.folderName = folderName;
|
||||
if (this.stateManager.getActiveVariantSettings(this.folderName) === null) {
|
||||
const defaultChoices = this.findDefaultChoiceCombination();
|
||||
await this.publishActiveKeywordSettings(defaultChoices);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ export class DirectoryContext {
|
|||
*/
|
||||
static createForDirectory(folder: vscode.WorkspaceFolder, state: StateManager): DirectoryContext {
|
||||
const config = ConfigurationReader.create(folder);
|
||||
state.setIsMultiProject(config.sourceDirectory.length > 1);
|
||||
return new DirectoryContext(folder, config, state);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче