Skip to content

Commit d538347

Browse files
committed
optimize UpdateView reloadproject
1 parent 1b45d5a commit d538347

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/EIDEProject.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
11461146
}
11471147

11481148
getFileGroups(): FileGroup[] {
1149-
return (<FileGroup[]>this.sourceRoots.getFileGroups())
1150-
.concat(this.virtualSource.getFileGroups());
1149+
return (<FileGroup[]>this.sourceRoots.getFileGroups()).concat(this.virtualSource.getFileGroups());
11511150
}
11521151

11531152
/**

src/EIDEProjectExplorer.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
913913
this.dataChangedEvent.fire(ele);
914914

915915
// whole treeview updated
916-
if (ele == undefined) {
917-
setTimeout(() => this.updateStatusBarForActiveProjects(), 500);
918-
}
916+
this.updateStatusBarForActiveProjects();
919917
}
920918

921919
private updateStatusBarForActiveProjects() {
@@ -955,9 +953,7 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
955953
return this.prjList[0];
956954
}
957955

958-
const index = this.prjList.findIndex((prj) => {
959-
return prj.getWsPath() == this.activePrjPath;
960-
});
956+
const index = this.prjList.findIndex((prj) => prj.getWsPath() == this.activePrjPath);
961957
if (index != -1) {
962958
return this.prjList[index];
963959
}
@@ -3765,7 +3761,7 @@ export class ProjectExplorer implements CustomConfigurationProvider {
37653761
const msg = view_str$prompt$need_reload_project.replace('{}', prj.getProjectName());
37663762
const ans = await vscode.window.showInformationMessage(msg, 'Yes', 'No');
37673763
if (ans == 'Yes') {
3768-
this.reloadProject(uid, wsf);
3764+
await this.reloadProject(uid, wsf);
37693765
}
37703766

37713767
if (this.__autosaveDisableTimeoutTimer) {
@@ -3779,20 +3775,28 @@ export class ProjectExplorer implements CustomConfigurationProvider {
37793775
this.enableAutoSave(true);
37803776
}
37813777

3782-
private reloadProject(uid: string, workspaceFile: File) {
3778+
private async reloadProject(uid: string, workspaceFile: File): Promise<boolean> {
37833779

37843780
const idx = this.dataProvider.getIndexByProjectUid(uid);
37853781
if (idx == -1) {
37863782
GlobalEvent.emit('msg', newMessage('Error', `Project '${uid}' is not actived !`));
3787-
return;
3783+
return false;
37883784
}
37893785

3790-
// close and reopen project
37913786
this.dataProvider.Close(idx);
3792-
this.dataProvider.OpenProject(workspaceFile.path, true);
37933787

3794-
// refresh explorer tree view
3795-
this.Refresh();
3788+
return new Promise((resolve) => {
3789+
setTimeout(async () => {
3790+
try {
3791+
await this.dataProvider.OpenProject(workspaceFile.path, true);
3792+
this.Refresh();
3793+
resolve(true);
3794+
} catch (error) {
3795+
GlobalEvent.emit('error', error);
3796+
resolve(false);
3797+
}
3798+
}, 500);
3799+
});
37963800
}
37973801

37983802
private async onProjectClosed(uid: string | undefined) {

0 commit comments

Comments
 (0)