From e383a4a08d1751dd9f24b01e02740bf6b2e507e3 Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Wed, 26 Feb 2025 11:52:34 -0800 Subject: [PATCH 1/2] Fix for automatically expanding AI search tree --- .../search/browser/searchActionsRemoveReplace.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts b/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts index ea1260b104f..b2861e96751 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,17 @@ 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))) { - await viewer.expand(navigator.current()); + // Never expand AI search results by default + if (navigator.current() instanceof AITextSearchHeadingImpl) { + return 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()); } } From 44bc117127ab572b59a2093c14da4f7bbcff3fc0 Mon Sep 17 00:00:00 2001 From: Osvaldo Ortega Date: Wed, 26 Feb 2025 12:11:27 -0800 Subject: [PATCH 2/2] Revert line deletion --- .../contrib/search/browser/searchActionsRemoveReplace.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts b/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts index b2861e96751..54d7b8f24d8 100644 --- a/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts +++ b/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.ts @@ -380,6 +380,7 @@ export async function getElementToFocusAfterRemoved(viewer: WorkbenchCompressibl if (navigator.current() instanceof AITextSearchHeadingImpl) { return navigator.current(); } + await viewer.expand(navigator.current()); } } else { while (navigator.next() && (!isSearchTreeMatch(navigator.current()) || arrayContainsElementOrParent(navigator.current(), elementsToRemove))) {