diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index dcd0abacbed690f3c2f9bd345f6f5de69829e6d6..e9f64e328f360abf661f4fc74871596d30d01b5e 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -157,6 +157,7 @@ const configurationValueWhitelist = [ 'breadcrumbs.enabled', 'breadcrumbs.filePath', 'breadcrumbs.symbolPath', + 'breadcrumbs.symbolSortOrder', 'breadcrumbs.useQuickPick', 'explorer.openEditors.visible', 'extensions.autoUpdate', diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbs.ts b/src/vs/workbench/browser/parts/editor/breadcrumbs.ts index 875b26ffe2f0199b10b46fc1fcee3132ba0fdd77..e5303fad2a9de036e16a35b5005701e128dc31a0 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbs.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbs.ts @@ -70,6 +70,7 @@ export abstract class BreadcrumbsConfig { static UseQuickPick = BreadcrumbsConfig._stub('breadcrumbs.useQuickPick'); static FilePath = BreadcrumbsConfig._stub<'on' | 'off' | 'last'>('breadcrumbs.filePath'); static SymbolPath = BreadcrumbsConfig._stub<'on' | 'off' | 'last'>('breadcrumbs.symbolPath'); + static SymbolSortOrder = BreadcrumbsConfig._stub<'position' | 'name' | 'type'>('breadcrumbs.symbolSortOrder'); static FilterOnType = BreadcrumbsConfig._stub('breadcrumbs.filterOnType'); static FileExcludes = BreadcrumbsConfig._stub('files.exclude'); @@ -142,6 +143,17 @@ Registry.as(Extensions.Configuration).registerConfigurat localize('symbolpath.last', "Only show the current symbol in the breadcrumbs view."), ] }, + 'breadcrumbs.symbolSortOrder': { + description: localize('symbolSortOrder', "Controls how symbols are sorted in the breadcrumbs outline view."), + type: 'string', + default: 'position', + enum: ['position', 'name', 'type'], + enumDescriptions: [ + localize('symbolSortOrder.position', "Show symbol outline in file position order."), + localize('symbolSortOrder.name', "Show symbol outline in alphabetical order."), + localize('symbolSortOrder.type', "Show symbol outline in symbol type order."), + ] + }, // 'breadcrumbs.filterOnType': { // description: localize('filterOnType', "Controls whether the breadcrumb picker filters or highlights when typing."), // type: 'boolean', diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts index 4000944371ab4ccf2d1a7827c75bb56426a60803..23ce7a08111441eacf85785cff1f1aab7f617800 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts @@ -18,7 +18,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IDataSource, IFilter, IRenderer, ISorter, ITree } from 'vs/base/parts/tree/browser/tree'; import 'vs/css!./media/breadcrumbscontrol'; import { OutlineElement, OutlineModel, TreeElement } from 'vs/editor/contrib/documentSymbols/outlineModel'; -import { OutlineDataSource, OutlineItemComparator, OutlineRenderer } from 'vs/editor/contrib/documentSymbols/outlineTree'; +import { OutlineDataSource, OutlineItemComparator, OutlineRenderer, OutlineItemCompareType } from 'vs/editor/contrib/documentSymbols/outlineTree'; import { localize } from 'vs/nls'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { FileKind, IFileService, IFileStat } from 'vs/platform/files/common/files'; @@ -52,6 +52,7 @@ export abstract class BreadcrumbsPicker { protected readonly _treeContainer: HTMLDivElement; protected readonly _tree: HighlightingWorkbenchTree; protected readonly _focus: dom.IFocusTracker; + protected readonly _symbolSortOrder: BreadcrumbsConfig<'position' | 'name' | 'type'>; private _layoutInfo: ILayoutInfo; private readonly _onDidPickElement = new Emitter<{ target: any, payload: any }>(); @@ -88,14 +89,16 @@ export abstract class BreadcrumbsPicker { this._treeContainer.style.boxShadow = `0px 5px 8px ${this._themeService.getTheme().getColor(widgetShadow)}`; this._domNode.appendChild(this._treeContainer); + this._symbolSortOrder = BreadcrumbsConfig.SymbolSortOrder.bindTo(this._configurationService); + const filterConfig = BreadcrumbsConfig.FilterOnType.bindTo(this._configurationService); this._disposables.push(filterConfig); - const treeConifg = this._completeTreeConfiguration({ dataSource: undefined, renderer: undefined, highlighter: undefined }); + const treeConfig = this._completeTreeConfiguration({ dataSource: undefined, renderer: undefined, highlighter: undefined }); this._tree = this._instantiationService.createInstance( HighlightingWorkbenchTree, this._treeContainer, - treeConifg, + treeConfig, { useShadows: false, filterOnType: filterConfig.getValue(), showTwistie: false, twistiePixels: 12 }, { placeholder: localize('placeholder', "Find") } ); @@ -144,6 +147,7 @@ export abstract class BreadcrumbsPicker { this._onDidPickElement.dispose(); this._tree.dispose(); this._focus.dispose(); + this._symbolSortOrder.dispose(); } setInput(input: any, maxHeight: number, width: number, arrowSize: number, arrowOffset: number): void { @@ -464,7 +468,7 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker { protected _completeTreeConfiguration(config: IHighlightingTreeConfiguration): IHighlightingTreeConfiguration { config.dataSource = this._instantiationService.createInstance(OutlineDataSource); config.renderer = this._instantiationService.createInstance(OutlineRenderer); - config.sorter = new OutlineItemComparator(); + config.sorter = new OutlineItemComparator(this._getOutlineItemComparator()); config.highlighter = new OutlineHighlighter(); return config; } @@ -477,6 +481,18 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker { return element; } } + + private _getOutlineItemComparator(): OutlineItemCompareType { + switch (this._symbolSortOrder.getValue()) { + case 'name': + return OutlineItemCompareType.ByName; + case 'type': + return OutlineItemCompareType.ByKind; + case 'position': + default: + return OutlineItemCompareType.ByPosition; + } + } } //#endregion