Merge pull request #59070 from Microsoft/octref/58555

Give hierarchy to the Open View quick pick. Fix #58555
This commit is contained in:
Pine 2018-10-24 10:04:30 -07:00 committed by GitHub
commit c9f7d10187
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,6 +102,13 @@ export class ViewPickerHandler extends QuickOpenHandler {
return true;
});
const entryToCategory = {};
entries.forEach(e => {
if (!entryToCategory[e.getLabel()]) {
entryToCategory[e.getLabel()] = e.getCategory();
}
});
let lastCategory: string;
entries.forEach((e, index) => {
if (lastCategory !== e.getCategory()) {
@ -109,6 +116,11 @@ export class ViewPickerHandler extends QuickOpenHandler {
e.setShowBorder(index > 0);
e.setGroupLabel(lastCategory);
// When the entry category has a parent category, set group label as Parent / Child. For example, Views / Explorer.
if (entryToCategory[lastCategory]) {
e.setGroupLabel(`${entryToCategory[lastCategory]} / ${lastCategory}`);
}
} else {
e.setShowBorder(false);
e.setGroupLabel(void 0);
@ -136,11 +148,11 @@ export class ViewPickerHandler extends QuickOpenHandler {
// Viewlets
const viewlets = this.viewletService.getViewlets();
viewlets.forEach((viewlet, index) => viewEntries.push(new ViewEntry(viewlet.name, nls.localize('views', "Views"), () => this.viewletService.openViewlet(viewlet.id, true))));
viewlets.forEach((viewlet, index) => viewEntries.push(new ViewEntry(viewlet.name, nls.localize('views', "Side Bar"), () => this.viewletService.openViewlet(viewlet.id, true))));
// Panels
const panels = this.panelService.getPanels();
panels.forEach((panel, index) => viewEntries.push(new ViewEntry(panel.name, nls.localize('panels', "Panels"), () => this.panelService.openPanel(panel.id, true))));
panels.forEach((panel, index) => viewEntries.push(new ViewEntry(panel.name, nls.localize('panels', "Panel"), () => this.panelService.openPanel(panel.id, true))));
// Viewlet Views
viewlets.forEach((viewlet, index) => {