Skip to content

Commit 0812181

Browse files
committed
Merge branch 'dev' of github.com:github0null/eide into dev
2 parents 1c535d4 + 62fa01a commit 0812181

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

src/EIDEProjectMigration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export async function doMigration(projectRootDir: File) {
2424
}
2525

2626
const prjCfg = ProjectConfiguration.parseProjectFile(projCfgFile.Read());
27+
28+
// version < 4.0 ?
2729
if (compareVersion(prjCfg.version, '4.0') < 0) {
2830
for (const key in prjCfg.targets) {
2931
const target = prjCfg.targets[key];
@@ -55,6 +57,10 @@ export async function doMigration(projectRootDir: File) {
5557
(<any>target)['custom_dep'] = undefined;
5658
}
5759
}
60+
}
61+
62+
// save
63+
if (compareVersion(prjCfg.version, EIDE_CONF_VERSION) < 0) {
5864
prjCfg.version = EIDE_CONF_VERSION;
5965
projCfgFile.Write(ProjectConfiguration.dumpProjectFile(prjCfg));
6066
}

src/EIDETypeDefine.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,36 @@ export class ProjectConfiguration<T extends BuilderConfigData>
511511
}
512512

513513
static dumpProjectFile<T>(obj: ProjectConfigData<T>): string {
514-
return yaml.stringify(obj, { indent: 2, lineWidth: 1000 });
514+
const keyOrder = [
515+
'version',
516+
'name',
517+
'type',
518+
'deviceName',
519+
'packDir',
520+
'srcDirs',
521+
'virtualFolder',
522+
'dependenceList',
523+
'outDir',
524+
'miscInfo',
525+
'targets'
526+
];
527+
return yaml.stringify(obj, {
528+
indent: 2,
529+
lineWidth: 1000,
530+
sortMapEntries: (a: any, b: any) => {
531+
const i_a = keyOrder.findIndex(e => e == a.key);
532+
const i_b = keyOrder.findIndex(e => e == b.key);
533+
if (i_a == -1 && i_b == -1) {
534+
return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
535+
} else if (i_a == -1) {
536+
return 1;
537+
} else if (i_b == -1) {
538+
return -1;
539+
} else {
540+
return i_a - i_b;
541+
}
542+
}
543+
});
515544
}
516545

517546
private __fileChgEvtEmitDelayTimer: NodeJS.Timeout | undefined;
@@ -757,7 +786,8 @@ export class ProjectConfiguration<T extends BuilderConfigData>
757786
this.config.compileConfig = this.compileConfigModel.data; // bind obj
758787

759788
// update
760-
this.compileConfigModel.copyCommonCompileConfigFrom(oldToolchain, oldModel);
789+
if (!oldCfg)
790+
this.compileConfigModel.copyCommonCompileConfigFrom(oldToolchain, oldModel);
761791
this.compileConfigModel.copyListenerFrom(oldModel);
762792
}
763793

@@ -1372,7 +1402,7 @@ export class ProjectConfiguration<T extends BuilderConfigData>
13721402
}
13731403

13741404
getProjectUsrCtx(): ProjectUserContextData {
1375-
const key = `eide.user-ctx.${this.config.miscInfo.uid || 'tmp'}`;
1405+
const key = `project.${this.config.miscInfo.uid || 'unknown'}`;
13761406
const val = this.workspaceState.get<string>(key);
13771407
if (!val)
13781408
return {};
@@ -1385,7 +1415,7 @@ export class ProjectConfiguration<T extends BuilderConfigData>
13851415
};
13861416

13871417
setProjectUsrCtx(data: ProjectUserContextData) {
1388-
const key = `eide.user-ctx.${this.config.miscInfo.uid || 'tmp'}`;
1418+
const key = `project.${this.config.miscInfo.uid || 'unknown'}`;
13891419
const val = this.workspaceState.get<string>(key);
13901420
const saveVal = JSON.stringify(data);
13911421
if (val !== saveVal) {

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export async function activate(context: vscode.ExtensionContext) {
310310
projectExplorer.enableAutoSave(true);
311311

312312
// load project in this workspace
313-
projectExplorer.loadWorkspace(context.workspaceState);
313+
projectExplorer.loadWorkspace(context.globalState);
314314

315315
// hook
316316
postLaunchHook(context);

0 commit comments

Comments
 (0)