mirror of
https://github.com/Microsoft/vscode
synced 2024-10-03 09:54:11 +00:00
breadcrumbs - show hellip when outline info is available but not intersecting with the current selection
This commit is contained in:
parent
a384b259e6
commit
48345b002d
|
@ -82,6 +82,12 @@ class Item extends BreadcrumbsItem {
|
|||
this._disposables.push(label);
|
||||
dom.toggleClass(container, 'file', this.element.isFile);
|
||||
|
||||
} else if (this.element instanceof OutlineModel) {
|
||||
// has outline element but not in one
|
||||
let label = document.createElement('div');
|
||||
label.innerHTML = '…';
|
||||
container.appendChild(label);
|
||||
|
||||
} else if (this.element instanceof OutlineGroup) {
|
||||
// provider
|
||||
let label = new IconLabel(container);
|
||||
|
@ -90,14 +96,12 @@ class Item extends BreadcrumbsItem {
|
|||
|
||||
} else if (this.element instanceof OutlineElement) {
|
||||
// symbol
|
||||
|
||||
if (this.options.showSymbolIcons) {
|
||||
let icon = document.createElement('div');
|
||||
icon.className = symbolKindToCssClass(this.element.symbol.kind);
|
||||
container.appendChild(icon);
|
||||
dom.addClass(container, 'shows-symbol-icon');
|
||||
}
|
||||
|
||||
let label = new IconLabel(container);
|
||||
let title = this.element.symbol.name.replace(/\r|\n|\r\n/g, '\u23CE');
|
||||
label.setValue(title, undefined, { title });
|
||||
|
|
|
@ -31,7 +31,7 @@ export class FileElement {
|
|||
) { }
|
||||
}
|
||||
|
||||
export type BreadcrumbElement = FileElement | OutlineGroup | OutlineElement;
|
||||
export type BreadcrumbElement = FileElement | OutlineModel | OutlineGroup | OutlineElement;
|
||||
|
||||
type FileInfo = { path: FileElement[], folder: IWorkspaceFolder, showFolder: boolean };
|
||||
|
||||
|
@ -43,7 +43,7 @@ export class EditorBreadcrumbsModel {
|
|||
private readonly _cfgFilePath: BreadcrumbsConfig<'on' | 'off' | 'last'>;
|
||||
private readonly _cfgSymbolPath: BreadcrumbsConfig<'on' | 'off' | 'last'>;
|
||||
|
||||
private _outlineElements: (OutlineGroup | OutlineElement)[] = [];
|
||||
private _outlineElements: (OutlineModel | OutlineGroup | OutlineElement)[] = [];
|
||||
private _outlineDisposables: IDisposable[] = [];
|
||||
|
||||
private _onDidUpdate = new Emitter<this>();
|
||||
|
@ -181,11 +181,14 @@ export class EditorBreadcrumbsModel {
|
|||
});
|
||||
}
|
||||
|
||||
private _getOutlineElements(model: OutlineModel, position: IPosition): (OutlineGroup | OutlineElement)[] {
|
||||
private _getOutlineElements(model: OutlineModel, position: IPosition): (OutlineModel | OutlineGroup | OutlineElement)[] {
|
||||
if (!model) {
|
||||
return [];
|
||||
}
|
||||
let item: OutlineGroup | OutlineElement = model.getItemEnclosingPosition(position);
|
||||
if (!item) {
|
||||
return [model];
|
||||
}
|
||||
let chain: (OutlineGroup | OutlineElement)[] = [];
|
||||
while (item) {
|
||||
chain.push(item);
|
||||
|
@ -201,14 +204,14 @@ export class EditorBreadcrumbsModel {
|
|||
return chain.reverse();
|
||||
}
|
||||
|
||||
private _updateOutlineElements(elements: (OutlineGroup | OutlineElement)[]): void {
|
||||
private _updateOutlineElements(elements: (OutlineModel | OutlineGroup | OutlineElement)[]): void {
|
||||
if (!equals(elements, this._outlineElements, EditorBreadcrumbsModel._outlineElementEquals)) {
|
||||
this._outlineElements = elements;
|
||||
this._onDidUpdate.fire(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static _outlineElementEquals(a: OutlineGroup | OutlineElement, b: OutlineGroup | OutlineElement): boolean {
|
||||
private static _outlineElementEquals(a: OutlineModel | OutlineGroup | OutlineElement, b: OutlineModel | OutlineGroup | OutlineElement): boolean {
|
||||
if (a === b) {
|
||||
return true;
|
||||
} else if (!a || !b) {
|
||||
|
|
|
@ -107,6 +107,10 @@ export abstract class BreadcrumbsPicker {
|
|||
this._tree.setFocus(selection);
|
||||
this._tree.domFocus();
|
||||
});
|
||||
} else {
|
||||
this._tree.focusFirst();
|
||||
this._tree.setSelection([this._tree.getFocus()], this._tree);
|
||||
this._tree.domFocus();
|
||||
}
|
||||
}, onUnexpectedError);
|
||||
}
|
||||
|
@ -278,7 +282,7 @@ export class BreadcrumbsOutlinePicker extends BreadcrumbsPicker {
|
|||
}
|
||||
|
||||
protected _getInitialSelection(_tree: ITree, input: BreadcrumbElement): any {
|
||||
return input;
|
||||
return input instanceof OutlineModel ? undefined : input;
|
||||
}
|
||||
|
||||
protected _completeTreeConfiguration(config: IHighlightingTreeConfiguration): IHighlightingTreeConfiguration {
|
||||
|
|
Loading…
Reference in a new issue