Skip to content

Commit 7efebe8

Browse files
authored
focus last (not first) symbol enclosing position, refines microsoft#154246 (microsoft#154340)
1 parent b4525a7 commit 7efebe8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { localize } from 'vs/nls';
2020
import { IQuickPick, IQuickPickItem, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
2121
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
2222
import { Position } from 'vs/editor/common/core/position';
23+
import { findLast } from 'vs/base/common/arrays';
2324

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

0 commit comments

Comments
 (0)