@@ -14,7 +14,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
1414import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
1515import { SearchResult } from 'vs/workbench/contrib/search/common/searchModel' ;
1616import { SearchEditor } from 'vs/workbench/contrib/searchEditor/browser/searchEditor' ;
17- import { getOrMakeSearchEditorInput , SearchEditorInput , SearchConfiguration } from 'vs/workbench/contrib/searchEditor/browser/searchEditorInput' ;
17+ import { getOrMakeSearchEditorInput , SearchEditorInput } from 'vs/workbench/contrib/searchEditor/browser/searchEditorInput' ;
1818import { serializeSearchResultForEditor } from 'vs/workbench/contrib/searchEditor/browser/searchEditorSerialization' ;
1919import { IEditorService , SIDE_GROUP , ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
2020import { ISearchConfigurationProperties } from 'vs/workbench/services/search/common/search' ;
@@ -25,6 +25,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
2525import { Schemas } from 'vs/base/common/network' ;
2626import { withNullAsUndefined } from 'vs/base/common/types' ;
2727import { OpenNewEditorCommandId } from 'vs/workbench/contrib/searchEditor/browser/constants' ;
28+ import { OpenSearchEditorArgs } from 'vs/workbench/contrib/searchEditor/browser/searchEditor.contribution' ;
2829
2930export const toggleSearchEditorCaseSensitiveCommand = ( accessor : ServicesAccessor ) => {
3031 const editorService = accessor . get ( IEditorService ) ;
@@ -99,7 +100,7 @@ export class OpenSearchEditorAction extends Action {
99100}
100101
101102export const openNewSearchEditor =
102- async ( accessor : ServicesAccessor , args : Partial < SearchConfiguration > = { } , toSide = false ) => {
103+ async ( accessor : ServicesAccessor , _args : OpenSearchEditorArgs = { } , toSide = false ) => {
103104 const editorService = accessor . get ( IEditorService ) ;
104105 const telemetryService = accessor . get ( ITelemetryService ) ;
105106 const instantiationService = accessor . get ( IInstantiationService ) ;
@@ -111,11 +112,6 @@ export const openNewSearchEditor =
111112 const activeWorkspaceRootUri = historyService . getLastActiveWorkspaceRoot ( Schemas . file ) ;
112113 const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined ( workspaceContextService . getWorkspaceFolder ( activeWorkspaceRootUri ) ) : undefined ;
113114
114- const resolvedArgs : Record < string , any > = { } ;
115- Object . entries ( args ) . forEach ( ( [ name , value ] ) => {
116- resolvedArgs [ name as any ] = ( typeof value === 'string' ) ? configurationResolverService . resolve ( lastActiveWorkspaceRoot , value ) : value ;
117- } ) ;
118-
119115 const activeEditorControl = editorService . activeTextEditorControl ;
120116 let activeModel : ICodeEditor | undefined ;
121117 let selected = '' ;
@@ -140,11 +136,20 @@ export const openNewSearchEditor =
140136
141137 telemetryService . publicLog2 ( 'searchEditor/openNewSearchEditor' ) ;
142138
143- const input = instantiationService . invokeFunction ( getOrMakeSearchEditorInput , { config : { query : selected , ...resolvedArgs } , text : '' } ) ;
139+ const args : Record < string , any > = { query : selected } ;
140+ Object . entries ( _args ) . forEach ( ( [ name , value ] ) => {
141+ args [ name as any ] = ( typeof value === 'string' ) ? configurationResolverService . resolve ( lastActiveWorkspaceRoot , value ) : value ;
142+ } ) ;
143+
144+ const input = instantiationService . invokeFunction ( getOrMakeSearchEditorInput , { config : args , text : '' } ) ;
144145 const editor = await editorService . openEditor ( input , { pinned : true } , toSide ? SIDE_GROUP : ACTIVE_GROUP ) as SearchEditor ;
145146
146- if ( selected && configurationService . getValue < ISearchConfigurationProperties > ( 'search' ) . searchOnType ) {
147- editor . triggerSearch ( ) ;
147+ const searchOnType = configurationService . getValue < ISearchConfigurationProperties > ( 'search' ) . searchOnType ;
148+ if (
149+ args . triggerSearch === true ||
150+ args . triggerSearch !== false && searchOnType && args . query
151+ ) {
152+ editor . triggerSearch ( { focusResults : args . focusResults !== false } ) ;
148153 }
149154 } ;
150155
0 commit comments