未验证 提交 d1206c6c 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #61420 from ryanclarke/master

Add sort option for breadcrumb symbol trees
......@@ -157,6 +157,7 @@ const configurationValueWhitelist = [
'breadcrumbs.enabled',
'breadcrumbs.filePath',
'breadcrumbs.symbolPath',
'breadcrumbs.symbolSortOrder',
'breadcrumbs.useQuickPick',
'explorer.openEditors.visible',
'extensions.autoUpdate',
......
......@@ -70,6 +70,7 @@ export abstract class BreadcrumbsConfig<T> {
static UseQuickPick = BreadcrumbsConfig._stub<boolean>('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<boolean>('breadcrumbs.filterOnType');
static FileExcludes = BreadcrumbsConfig._stub<glob.IExpression>('files.exclude');
......@@ -142,6 +143,17 @@ Registry.as<IConfigurationRegistry>(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',
......
......@@ -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,
<IHighlightingTreeOptions>{ 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册