提交 20f06ed0 编写于 作者: J Johannes Rieken

make OutlineGroup fit for being used with other things than providers, #95234

上级 88e98034
......@@ -120,14 +120,14 @@ export class OutlineGroup extends TreeElement {
constructor(
readonly id: string,
public parent: TreeElement | undefined,
readonly provider: DocumentSymbolProvider,
readonly providerIndex: number,
readonly label: string,
readonly order: number,
) {
super();
}
adopt(parent: TreeElement): OutlineGroup {
let res = new OutlineGroup(this.id, parent, this.provider, this.providerIndex);
let res = new OutlineGroup(this.id, parent, this.label, this.order);
for (const [key, value] of this.children) {
res.children.set(key, value.adopt(res));
}
......@@ -320,7 +320,7 @@ export class OutlineModel extends TreeElement {
const promises = provider.map((provider, index) => {
let id = TreeElement.findId(`provider_${index}`, result);
let group = new OutlineGroup(id, result, provider, index);
let group = new OutlineGroup(id, result, provider.displayName ?? 'Unknown Outline Provider', index);
return Promise.resolve(provider.provideDocumentSymbols(result.textModel, cts.token)).then(result => {
for (const info of result || []) {
......
......@@ -32,7 +32,7 @@ export class OutlineNavigationLabelProvider implements IKeyboardNavigationLabelP
getKeyboardNavigationLabel(element: OutlineItem): { toString(): string; } {
if (element instanceof OutlineGroup) {
return element.provider.displayName || element.id;
return element.label;
} else {
return element.symbol.name;
}
......@@ -43,7 +43,7 @@ export class OutlineAccessibilityProvider implements IListAccessibilityProvider<
getAriaLabel(element: OutlineItem): string | null {
if (element instanceof OutlineGroup) {
return element.provider.displayName || element.id;
return element.label;
} else {
return element.symbol.name;
}
......@@ -102,7 +102,7 @@ export class OutlineGroupRenderer implements ITreeRenderer<OutlineGroup, FuzzySc
renderElement(node: ITreeNode<OutlineGroup, FuzzyScore>, index: number, template: OutlineGroupTemplate): void {
template.label.set(
node.element.provider.displayName || localize('provider', "Outline Provider"),
node.element.label,
createMatches(node.filterData)
);
}
......@@ -324,7 +324,7 @@ export class OutlineItemComparator implements ITreeSorter<OutlineItem> {
compare(a: OutlineItem, b: OutlineItem): number {
if (a instanceof OutlineGroup && b instanceof OutlineGroup) {
return a.providerIndex - b.providerIndex;
return a.order - b.order;
} else if (a instanceof OutlineElement && b instanceof OutlineElement) {
if (this.type === OutlineSortOrder.ByKind) {
......
......@@ -104,7 +104,7 @@ class Item extends BreadcrumbsItem {
} else if (this.element instanceof OutlineGroup) {
// provider
let label = new IconLabel(container);
label.setLabel(this.element.provider.displayName || '');
label.setLabel(this.element.label);
this._disposables.add(label);
} else if (this.element instanceof OutlineElement) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册