[cm6] Avoid selecting a search match when re-opening the search panel (#12797)

GitOrigin-RevId: 32bb03b71ce56cc0dbe6f7c92cc6d85151ef1971
This commit is contained in:
Alf Eaton 2023-04-28 09:41:24 +01:00 committed by Copybot
parent 40cbfc451a
commit 1da94f029c
2 changed files with 6 additions and 1 deletions

View file

@ -126,6 +126,11 @@ export const search = () => {
// select a match while searching // select a match while searching
EditorView.updateListener.of(update => { 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) { for (const tr of update.transactions) {
// avoid changing the selection and viewport when switching between files // avoid changing the selection and viewport when switching between files
if (tr.annotation(restoreSearchQueryAnnotation)) { if (tr.annotation(restoreSearchQueryAnnotation)) {

View file

@ -221,7 +221,7 @@ contentLine3
// Search should now be open at first match // Search should now be open at first match
cy.findByRole('search').should('have.length', 1) 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 // Repeated C-r should go to previous match
cy.get('@search-input').type('{ctrl}r') cy.get('@search-input').type('{ctrl}r')