diff --git a/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts b/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts index ea1260b104f..54d7b8f24d8 100644 --- a/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts +++ b/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts @@ -24,6 +24,7 @@ import { category, getElementsToOperateOn, getSearchView, shouldRefocus } from ' import { equals } from '../../../../base/common/arrays.js'; import { arrayContainsElementOrParent, RenderableMatch, ISearchResult, isSearchTreeFileMatch, isSearchTreeFolderMatch, isSearchTreeMatch, isSearchResult, isTextSearchHeading } from './searchTreeModel/searchTreeCommon.js'; import { MatchInNotebook } from './notebookSearch/notebookSearchModel.js'; +import { AITextSearchHeadingImpl } from './AISearch/aiSearchModel.js'; //#region Interfaces @@ -375,10 +376,18 @@ export async function getElementToFocusAfterRemoved(viewer: WorkbenchCompressibl while (!!navigator.next() && (!isSearchTreeFolderMatch(navigator.current()) || arrayContainsElementOrParent(navigator.current(), elementsToRemove))) { } } else if (isSearchTreeFileMatch(element)) { while (!!navigator.next() && (!isSearchTreeFileMatch(navigator.current()) || arrayContainsElementOrParent(navigator.current(), elementsToRemove))) { + // Never expand AI search results by default + if (navigator.current() instanceof AITextSearchHeadingImpl) { + return navigator.current(); + } await viewer.expand(navigator.current()); } } else { while (navigator.next() && (!isSearchTreeMatch(navigator.current()) || arrayContainsElementOrParent(navigator.current(), elementsToRemove))) { + // Never expand AI search results by default + if (navigator.current() instanceof AITextSearchHeadingImpl) { + return navigator.current(); + } await viewer.expand(navigator.current()); } }