Skip to content

Commit

Permalink
focus last (not first) symbol enclosing position, refines #154246
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 7, 2022
1 parent 0284e1b commit afba190
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { localize } from 'vs/nls';
import { IQuickPick, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
import { Position } from 'vs/editor/common/core/position';
import { findLast } from 'vs/base/common/arrays';

export interface IGotoSymbolQuickPickItem extends IQuickPickItem {
kind: SymbolKind;
Expand Down Expand Up @@ -177,7 +178,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
if (items.length > 0) {
picker.items = items;
if (positionToEnclose && query.original.length === 0) {
const candidate = <IGotoSymbolQuickPickItem | undefined>items.find(item => item.type !== 'separator' && item.range && Range.containsPosition(item.range.decoration, positionToEnclose));
const candidate = <IGotoSymbolQuickPickItem>findLast(items, item => Boolean(item.type !== 'separator' && item.range && Range.containsPosition(item.range.decoration, positionToEnclose)));
if (candidate) {
picker.activeItems = [candidate];
}
Expand Down

0 comments on commit afba190

Please sign in to comment.