@@ -47,6 +47,8 @@ interface IFolderMatchTemplate {
47
47
interface ITextSearchResultTemplate {
48
48
label : IResourceLabel ;
49
49
disposables : DisposableStore ;
50
+ actions : MenuWorkbenchToolBar ;
51
+ contextKeyService : IContextKeyService ;
50
52
}
51
53
52
54
interface IFileMatchTemplate {
@@ -102,7 +104,9 @@ export class TextSearchResultRenderer extends Disposable implements ICompressibl
102
104
103
105
constructor (
104
106
private labels : ResourceLabels ,
105
- @IWorkspaceContextService protected contextService : IWorkspaceContextService
107
+ @IWorkspaceContextService protected contextService : IWorkspaceContextService ,
108
+ @IInstantiationService private readonly instantiationService : IInstantiationService ,
109
+ @IContextKeyService private readonly contextKeyService : IContextKeyService ,
106
110
) {
107
111
super ( ) ;
108
112
}
@@ -114,12 +118,31 @@ export class TextSearchResultRenderer extends Disposable implements ICompressibl
114
118
const textSearchResultElement = DOM . append ( container , DOM . $ ( '.textsearchresult' ) ) ;
115
119
const label = this . labels . create ( textSearchResultElement , { supportDescriptionHighlights : true , supportHighlights : true , supportIcons : true } ) ;
116
120
disposables . add ( label ) ;
117
- return { label, disposables } ;
121
+
122
+ const actionBarContainer = DOM . append ( textSearchResultElement , DOM . $ ( '.actionBarContainer' ) ) ;
123
+ const contextKeyServiceMain = disposables . add ( this . contextKeyService . createScoped ( container ) ) ;
124
+
125
+ const instantiationService = disposables . add ( this . instantiationService . createChild ( new ServiceCollection ( [ IContextKeyService , contextKeyServiceMain ] ) ) ) ;
126
+ const actions = disposables . add ( instantiationService . createInstance ( MenuWorkbenchToolBar , actionBarContainer , MenuId . SearchActionMenu , {
127
+ menuOptions : {
128
+ shouldForwardArgs : true
129
+ } ,
130
+ highlightToggledItems : true ,
131
+ hiddenItemStrategy : HiddenItemStrategy . Ignore ,
132
+ toolbarOptions : {
133
+ primaryGroup : ( g : string ) => / ^ i n l i n e / . test ( g ) ,
134
+ } ,
135
+ } ) ) ;
136
+ return { label, disposables, actions, contextKeyService : contextKeyServiceMain } ;
118
137
}
119
138
120
139
async renderElement ( node : ITreeNode < ITextSearchHeading , any > , index : number , templateData : IFolderMatchTemplate , height : number | undefined ) : Promise < void > {
121
140
if ( isPlainTextSearchHeading ( node . element ) ) {
122
141
templateData . label . setLabel ( nls . localize ( 'searchFolderMatch.plainText.label' , "Text Results" ) ) ;
142
+ SearchContext . AIResultsTitle . bindTo ( templateData . contextKeyService ) . set ( false ) ;
143
+ SearchContext . MatchFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
144
+ SearchContext . FileFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
145
+ SearchContext . FolderFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
123
146
} else {
124
147
const aiName = await node . element . parent ( ) . searchModel . getAITextResultProviderName ( ) ;
125
148
const localizedLabel = nls . localize ( {
@@ -129,6 +152,11 @@ export class TextSearchResultRenderer extends Disposable implements ICompressibl
129
152
130
153
// todo: make icon extension-contributed.
131
154
templateData . label . setLabel ( `$(${ Codicon . copilot . id } ) ${ localizedLabel } ` ) ;
155
+
156
+ SearchContext . AIResultsTitle . bindTo ( templateData . contextKeyService ) . set ( true ) ;
157
+ SearchContext . MatchFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
158
+ SearchContext . FileFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
159
+ SearchContext . FolderFocusKey . bindTo ( templateData . contextKeyService ) . set ( false ) ;
132
160
}
133
161
}
134
162
@@ -188,6 +216,7 @@ export class FolderMatchRenderer extends Disposable implements ICompressibleTree
188
216
disposables . add ( elementDisposables ) ;
189
217
190
218
const contextKeyServiceMain = disposables . add ( this . contextKeyService . createScoped ( container ) ) ;
219
+ SearchContext . AIResultsTitle . bindTo ( contextKeyServiceMain ) . set ( false ) ;
191
220
SearchContext . MatchFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
192
221
SearchContext . FileFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
193
222
SearchContext . FolderFocusKey . bindTo ( contextKeyServiceMain ) . set ( true ) ;
@@ -288,6 +317,7 @@ export class FileMatchRenderer extends Disposable implements ICompressibleTreeRe
288
317
const actionBarContainer = DOM . append ( fileMatchElement , DOM . $ ( '.actionBarContainer' ) ) ;
289
318
290
319
const contextKeyServiceMain = disposables . add ( this . contextKeyService . createScoped ( container ) ) ;
320
+ SearchContext . AIResultsTitle . bindTo ( contextKeyServiceMain ) . set ( false ) ;
291
321
SearchContext . MatchFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
292
322
SearchContext . FileFocusKey . bindTo ( contextKeyServiceMain ) . set ( true ) ;
293
323
SearchContext . FolderFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
@@ -380,6 +410,7 @@ export class MatchRenderer extends Disposable implements ICompressibleTreeRender
380
410
const disposables = new DisposableStore ( ) ;
381
411
382
412
const contextKeyServiceMain = disposables . add ( this . contextKeyService . createScoped ( container ) ) ;
413
+ SearchContext . AIResultsTitle . bindTo ( contextKeyServiceMain ) . set ( false ) ;
383
414
SearchContext . MatchFocusKey . bindTo ( contextKeyServiceMain ) . set ( true ) ;
384
415
SearchContext . FileFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
385
416
SearchContext . FolderFocusKey . bindTo ( contextKeyServiceMain ) . set ( false ) ;
0 commit comments