Skip to content

Commit

Permalink
fix go to symbol in accessible view (#236624)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge authored Dec 19, 2024
1 parent d55cb9a commit fe68aa5
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/vs/workbench/contrib/accessibility/browser/accessibleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
private _hasAssignedKeybindings: IContextKey<boolean>;

private _codeBlocks?: ICodeBlock[];
private _inQuickPick: boolean = false;
private _isInQuickPick: boolean = false;

get editorWidget() { return this._editorWidget; }
private _container: HTMLElement;
Expand Down Expand Up @@ -352,6 +352,7 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
if (!this._currentProvider) {
return;
}
this._isInQuickPick = true;
this._instantiationService.createInstance(AccessibleViewSymbolQuickPick, this).show(this._currentProvider);
}

Expand Down Expand Up @@ -388,11 +389,11 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
}

getSymbols(): IAccessibleViewSymbol[] | undefined {
const provider = this._currentProvider instanceof AccessibleContentProvider ? this._currentProvider : undefined;
const provider = this._currentProvider ? this._currentProvider : undefined;
if (!this._currentContent || !provider) {
return;
}
const symbols: IAccessibleViewSymbol[] = provider.getSymbols?.() || [];
const symbols: IAccessibleViewSymbol[] = 'getSymbols' in provider ? provider.getSymbols?.() || [] : [];
if (symbols?.length) {
return symbols;
}
Expand All @@ -416,7 +417,7 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
}

configureKeybindings(unassigned: boolean): void {
this._inQuickPick = true;
this._isInQuickPick = true;
const provider = this._updateLastProvider();
const items = unassigned ? provider?.options?.configureKeybindingItems : provider?.options?.configuredKeybindingItems;
if (!items) {
Expand All @@ -440,7 +441,7 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
this.show(provider);
}
disposables.dispose();
this._inQuickPick = false;
this._isInQuickPick = false;
}));
}

Expand Down Expand Up @@ -495,6 +496,7 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
if (lineNumber === undefined) {
return;
}
this._isInQuickPick = false;
this.show(provider, undefined, undefined, { lineNumber, column: 1 });
this._updateContextKeys(provider, true);
}
Expand Down Expand Up @@ -609,11 +611,14 @@ export class AccessibleView extends Disposable implements ITextModelContentProvi
this._updateToolbar(this._currentProvider.actions, provider.options.type);

const hide = (e?: KeyboardEvent | IKeyboardEvent): void => {
if (!this._inQuickPick) {
if (!this._isInQuickPick) {
provider.onClose();
}
e?.stopPropagation();
this._contextViewService.hideContextView();
if (this._isInQuickPick) {
return;
}
this._updateContextKeys(provider, false);
this._lastProvider = undefined;
this._currentContent = undefined;
Expand Down Expand Up @@ -938,11 +943,15 @@ class AccessibleViewSymbolQuickPick {
for (const symbol of symbols) {
picks.push({
label: symbol.label,
ariaLabel: symbol.ariaLabel
ariaLabel: symbol.ariaLabel,
firstListItem: symbol.firstListItem,
lineNumber: symbol.lineNumber,
endLineNumber: symbol.endLineNumber,
markdownToParse: symbol.markdownToParse
});
}
quickPick.canSelectMany = false;
quickPick.items = symbols;
quickPick.items = picks;
quickPick.show();
disposables.add(quickPick.onDidAccept(() => {
this._accessibleView.showSymbol(provider, quickPick.selectedItems[0]);
Expand Down

0 comments on commit fe68aa5

Please sign in to comment.