Skip to content

Commit 3b771d3

Browse files
committed
fix microsoft#100215. focus the nearest result when loop is disabled.
1 parent 1d2af09 commit 3b771d3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/vs/editor/contrib/find/findModel.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ export class FindModelBoundToEditorModel {
262262

263263
private _moveToPrevMatch(before: Position, isRecursed: boolean = false): void {
264264
if (!this._state.canNavigateBack()) {
265+
// we are beyond the first matched find result
266+
// instead of doing nothing, we should refocus the first item
267+
const nextMatchRange = this._decorations.matchAfterPosition(before);
268+
269+
if (nextMatchRange) {
270+
this._setCurrentFindMatch(nextMatchRange);
271+
}
265272
return;
266273
}
267274
if (this._decorations.getCount() < MATCHES_LIMIT) {
@@ -350,6 +357,13 @@ export class FindModelBoundToEditorModel {
350357

351358
private _moveToNextMatch(after: Position): void {
352359
if (!this._state.canNavigateForward()) {
360+
// we are beyond the last matched find result
361+
// instead of doing nothing, we should refocus the last item
362+
const prevMatchRange = this._decorations.matchBeforePosition(after);
363+
364+
if (prevMatchRange) {
365+
this._setCurrentFindMatch(prevMatchRange);
366+
}
353367
return;
354368
}
355369
if (this._decorations.getCount() < MATCHES_LIMIT) {

0 commit comments

Comments
 (0)