diff --git a/services/web/frontend/js/features/source-editor/extensions/search.ts b/services/web/frontend/js/features/source-editor/extensions/search.ts index 3aa31a59ef..2e3eaeebd2 100644 --- a/services/web/frontend/js/features/source-editor/extensions/search.ts +++ b/services/web/frontend/js/features/source-editor/extensions/search.ts @@ -126,6 +126,11 @@ export const search = () => { // select a match while searching EditorView.updateListener.of(update => { + // if the search panel wasn't open, don't select a match + if (!searchPanelOpen(update.startState)) { + return + } + for (const tr of update.transactions) { // avoid changing the selection and viewport when switching between files if (tr.annotation(restoreSearchQueryAnnotation)) { diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx index 486a21ce04..e57a0e8572 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx @@ -221,7 +221,7 @@ contentLine3 // Search should now be open at first match cy.findByRole('search').should('have.length', 1) - cy.contains(`1 of 3`) + cy.contains(`0 of 3`) // Repeated C-r should go to previous match cy.get('@search-input').type('{ctrl}r')