提交 cece1a4f 编写于 作者: J Johannes Rieken

use identity provider, some cleanup

上级 88c271c3
......@@ -64,9 +64,10 @@ class OutlineItem extends BreadcrumbsItem {
if (!(other instanceof OutlineItem)) {
return false;
}
return this.element === other.element &&
this.options.showFileIcons === other.options.showFileIcons &&
this.options.showSymbolIcons === other.options.showSymbolIcons;
return this.element.outline.config.identityProvider.getId(this.element.element) === other.element.outline.config.identityProvider.getId(other.element.element);
// return this.element === other.element &&
// this.options.showFileIcons === other.options.showFileIcons &&
// this.options.showSymbolIcons === other.options.showSymbolIcons;
}
render(container: HTMLElement): void {
......@@ -78,8 +79,8 @@ class OutlineItem extends BreadcrumbsItem {
return;
}
const templateId = outline.treeConfig.delegate.getTemplateId(element);
const renderer = outline.treeConfig.renderers.find(renderer => renderer.templateId === templateId);
const templateId = outline.config.delegate.getTemplateId(element);
const renderer = outline.config.renderers.find(renderer => renderer.templateId === templateId);
if (!renderer) {
container.innerText = '<<NO RENDERER>>';
return;
......@@ -477,7 +478,7 @@ export class BreadcrumbsControl {
this._widget.setSelection(items[idx + 1], BreadcrumbsControl.Payload_Pick);
}
} else {
element.outline.revealInEditor(element, { pinned }, group === SIDE_GROUP);
element.outline.reveal(element, { pinned }, group === SIDE_GROUP);
}
}
......
......@@ -105,7 +105,7 @@ export class BreadcrumbsModel {
const { activeEntry } = this._currentOutline;
if (activeEntry) {
for (let element of this._currentOutline.treeConfig.breadcrumbsDataSource.getBreadcrumbElements(activeEntry)) {
for (let element of this._currentOutline.config.breadcrumbsDataSource.getBreadcrumbElements(activeEntry)) {
result.push(new OutlineElement2(element, this._currentOutline));
}
} else if (!this._currentOutline.isEmpty) {
......
......@@ -470,23 +470,23 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
protected _createTree(container: HTMLElement, input: OutlineElement2) {
const { treeConfig } = input.outline;
const { config } = input.outline;
return <WorkbenchDataTree<IOutline<any>, any, FuzzyScore>>this._instantiationService.createInstance(
WorkbenchDataTree,
'BreadcrumbsOutlinePicker',
container,
treeConfig.delegate,
treeConfig.renderers,
treeConfig.treeDataSource,
config.delegate,
config.renderers,
config.treeDataSource,
{
collapseByDefault: true,
expandOnlyOnTwistieClick: true,
multipleSelectionSupport: false,
sorter: this._outlineComparator,
identityProvider: treeConfig.identProvider,
identityProvider: config.identityProvider,
keyboardNavigationLabelProvider: new OutlineNavigationLabelProvider(),
accessibilityProvider: treeConfig.options.accessibilityProvider,
accessibilityProvider: config.options.accessibilityProvider,
filter: this._instantiationService.createInstance(OutlineFilter, 'breadcrumbs')
}
);
......@@ -521,12 +521,12 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
protected _previewElement(element: any): IDisposable {
const outline: IOutline<any> = this._tree.getInput();
return outline.previewInEditor(element);
return outline.preview(element);
}
async _revealElement(element: any, options: IEditorOptions, sideBySide: boolean): Promise<boolean> {
const outline: IOutline<any> = this._tree.getInput();
await outline.revealInEditor(element, options, sideBySide);
await outline.reveal(element, options, sideBySide);
return true;
}
......
......@@ -46,7 +46,7 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
private _outlineElementChain: Array<OutlineModel | OutlineGroup | OutlineElement> = [];
private _outlineDisposables = new DisposableStore();
readonly treeConfig: OutlineTreeConfiguration<DocumentSymbolItem>;
readonly config: OutlineTreeConfiguration<DocumentSymbolItem>;
constructor(
private readonly _editor: ICodeEditor,
......@@ -56,7 +56,7 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
@IInstantiationService instantiationService: IInstantiationService,
) {
this.treeConfig = new OutlineTreeConfiguration(
this.config = new OutlineTreeConfiguration(
{
getBreadcrumbElements: () => <DocumentSymbolItem[]>this._outlineElementChain.filter(element => !(element instanceof OutlineModel))
},
......@@ -139,7 +139,7 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
return candidate instanceof OutlineModel ? undefined : candidate;
}
async revealInEditor(entry: DocumentSymbolItem, options: IEditorOptions, sideBySide: boolean): Promise<void> {
async reveal(entry: DocumentSymbolItem, options: IEditorOptions, sideBySide: boolean): Promise<void> {
if (entry instanceof OutlineElement) {
const position = Range.getStartPosition(entry.symbol.selectionRange);
this._editor.revealPositionInCenterIfOutsideViewport(position, ScrollType.Immediate);
......@@ -161,7 +161,7 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
}, this._editor, sideBySide);
}
previewInEditor(entry: DocumentSymbolItem): IDisposable {
preview(entry: DocumentSymbolItem): IDisposable {
if (!(entry instanceof OutlineElement)) {
return Disposable.None;
}
......
......@@ -150,7 +150,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
disposables.add(outline);
const entries = Array.from(outline.treeConfig.quickPickDataSource.getQuickPickElements());
const entries = Array.from(outline.config.quickPickDataSource.getQuickPickElements());
const items: IGotoSymbolQuickPickItem[] = entries.map((entry, idx) => {
return {
......@@ -167,7 +167,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
picker.hide();
const [entry] = picker.selectedItems;
if (entry && entries[entry.index]) {
outline.revealInEditor(entries[entry.index].element, {}, false);
outline.reveal(entries[entry.index].element, {}, false);
}
}));
......@@ -204,7 +204,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
disposables.add(picker.onDidChangeActive(() => {
const [entry] = picker.activeItems;
if (entry && entries[entry.index]) {
previewDisposable.value = outline.previewInEditor(entries[entry.index].element);
previewDisposable.value = outline.preview(entries[entry.index].element);
} else {
previewDisposable.clear();
}
......
......@@ -100,7 +100,7 @@ class NotebookCellOutline implements IOutline<OutlineEntry> {
private _entries: OutlineEntry[] = [];
private readonly _entriesDisposables = new DisposableStore();
readonly treeConfig: OutlineTreeConfiguration<OutlineEntry>;
readonly config: OutlineTreeConfiguration<OutlineEntry>;
constructor(
private readonly _editor: NotebookEditor,
......@@ -131,7 +131,7 @@ class NotebookCellOutline implements IOutline<OutlineEntry> {
this._computeActive();
installSelectionListener();
this.treeConfig = new OutlineTreeConfiguration<OutlineEntry>(
this.config = new OutlineTreeConfiguration<OutlineEntry>(
{ getBreadcrumbElements: (element) => Iterable.single(element) },
{ getQuickPickElements: () => this._entries.map(entry => ({ element: entry, label: `$(${entry.icon.id}) ${entry.label}`, ariaLabel: entry.label })) },
{ getChildren: parent => parent === this ? this._entries : [] },
......@@ -209,14 +209,7 @@ class NotebookCellOutline implements IOutline<OutlineEntry> {
return this._activeEntry;
}
async revealInEditor(entry: OutlineEntry, options: IEditorOptions, sideBySide: boolean): Promise<void> {
//todo@jrieken focus cell
// const widget = this._editor.getControl();
// if (widget) {
// widget.revealInCenterIfOutsideViewport(entry.cell);
// widget.selectElement(entry.cell);
// widget.focusNotebookCell(entry.cell, entry.cell.cellKind === CellKind.Markdown ? 'container' : 'editor');
// }
async reveal(entry: OutlineEntry, options: IEditorOptions, sideBySide: boolean): Promise<void> {
await this._editorService.openEditor({
resource: entry.cell.uri,
......@@ -224,7 +217,7 @@ class NotebookCellOutline implements IOutline<OutlineEntry> {
}, sideBySide ? SIDE_GROUP : undefined);
}
previewInEditor(entry: OutlineEntry): IDisposable {
preview(entry: OutlineEntry): IDisposable {
const widget = this._editor.getControl();
if (!widget) {
return Disposable.None;
......
......@@ -45,7 +45,7 @@ export class OutlineTreeConfiguration<E> {
readonly treeDataSource: IDataSource<IOutline<E>, E>,
readonly delegate: IListVirtualDelegate<E>,
readonly renderers: ITreeRenderer<E, FuzzyScore, any>[],
readonly identProvider: IIdentityProvider<E>,
readonly identityProvider: IIdentityProvider<E>,
readonly options: IWorkbenchDataTreeOptions<E, FuzzyScore>,
) { }
}
......@@ -54,7 +54,7 @@ export interface IOutline<E> {
dispose(): void;
readonly treeConfig: OutlineTreeConfiguration<E>
readonly config: OutlineTreeConfiguration<E>
readonly onDidChange: Event<this>;
......@@ -62,6 +62,6 @@ export interface IOutline<E> {
readonly activeEntry: E | undefined;
readonly onDidChangeActiveEntry: Event<this>
revealInEditor(entry: E, options: IEditorOptions, sideBySide: boolean): Promise<void> | void;
previewInEditor(entry: E): IDisposable;
reveal(entry: E, options: IEditorOptions, sideBySide: boolean): Promise<void> | void;
preview(entry: E): IDisposable;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册