Skip to content

Commit

Permalink
update navigator context menu on supportMultiRootWorkspace changed
Browse files Browse the repository at this point in the history
- fixes #4099

Signed-off-by: elaihau <[email protected]>
  • Loading branch information
elaihau authored and elaihau committed Jan 23, 2019
1 parent f143065 commit 831ad92
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,17 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi

this.workspacePreferences.ready.then(() => {
if (this.workspacePreferences['workspace.supportMultiRootWorkspace']) {
registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.ADD_FOLDER.id
});
registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.REMOVE_FOLDER.id
});
this.registerAddRemoveFolderActions(registry);
}
this.workspacePreferences.onPreferenceChanged(change => {
if (change.preferenceName === 'workspace.supportMultiRootWorkspace') {
if (change.newValue) {
this.registerAddRemoveFolderActions(registry);
} else {
this.unregisterAddRemoveFolderActions(registry);
}
}
});
});
}

Expand Down Expand Up @@ -266,4 +270,17 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
}
}

private registerAddRemoveFolderActions(registry: MenuModelRegistry): void {
registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.ADD_FOLDER.id
});
registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.REMOVE_FOLDER.id
});
}

private unregisterAddRemoveFolderActions(registry: MenuModelRegistry): void {
registry.unregisterMenuAction({ commandId: WorkspaceCommands.ADD_FOLDER.id }, NavigatorContextMenu.WORKSPACE);
registry.unregisterMenuAction({ commandId: WorkspaceCommands.REMOVE_FOLDER.id }, NavigatorContextMenu.WORKSPACE);
}
}

0 comments on commit 831ad92

Please sign in to comment.