@@ -34,6 +34,8 @@ import { SEARCH_RESULT_LANGUAGE_ID } from 'vs/workbench/services/search/common/s
34
34
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory' ;
35
35
import { IHoverService } from 'vs/platform/hover/browser/hover' ;
36
36
import { ChatAgentLocation , IChatAgent , IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
37
+ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
38
+ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent' ;
37
39
38
40
const $ = dom . $ ;
39
41
@@ -60,6 +62,7 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
60
62
@IChatAgentService private readonly chatAgentService : IChatAgentService ,
61
63
@ITelemetryService private readonly telemetryService : ITelemetryService ,
62
64
@IProductService protected readonly productService : IProductService ,
65
+ @IContextMenuService private readonly contextMenuService : IContextMenuService
63
66
) {
64
67
this . toDispose = [ ] ;
65
68
this . toDispose . push ( this . editor . onDidChangeModel ( ( ) => this . update ( ) ) ) ;
@@ -145,7 +148,8 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
145
148
this . keybindingService ,
146
149
this . chatAgentService ,
147
150
this . telemetryService ,
148
- this . productService
151
+ this . productService ,
152
+ this . contextMenuService
149
153
) ;
150
154
} else if ( ! shouldRenderHint && this . textHintContentWidget ) {
151
155
this . textHintContentWidget . dispose ( ) ;
@@ -178,7 +182,8 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
178
182
private readonly keybindingService : IKeybindingService ,
179
183
private readonly chatAgentService : IChatAgentService ,
180
184
private readonly telemetryService : ITelemetryService ,
181
- private readonly productService : IProductService
185
+ private readonly productService : IProductService ,
186
+ private readonly contextMenuService : IContextMenuService ,
182
187
) {
183
188
this . toDispose = new DisposableStore ( ) ;
184
189
this . toDispose . add ( this . editor . onDidChangeConfiguration ( ( e : ConfigurationChangedEvent ) => {
@@ -199,10 +204,34 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
199
204
return EmptyTextEditorHintContentWidget . ID ;
200
205
}
201
206
202
- private _disableHint ( ) {
203
- this . configurationService . updateValue ( emptyTextEditorHintSetting , 'hidden' ) ;
204
- this . dispose ( ) ;
205
- this . editor . focus ( ) ;
207
+ private _disableHint ( e ?: MouseEvent ) {
208
+ const disableHint = ( ) => {
209
+ this . configurationService . updateValue ( emptyTextEditorHintSetting , 'hidden' ) ;
210
+ this . dispose ( ) ;
211
+ this . editor . focus ( ) ;
212
+ } ;
213
+
214
+ if ( ! e ) {
215
+ disableHint ( ) ;
216
+ return ;
217
+ }
218
+
219
+ this . contextMenuService . showContextMenu ( {
220
+ getAnchor : ( ) => { return new StandardMouseEvent ( dom . getActiveWindow ( ) , e ) ; } ,
221
+ getActions : ( ) => {
222
+ return [ {
223
+ id : 'workench.action.disableEmptyEditorHint' ,
224
+ label : localize ( 'disableEditorEmptyHint' , "Disable Empty Editor Hint" ) ,
225
+ tooltip : localize ( 'disableEditorEmptyHint' , "Disable Empty Editor Hint" ) ,
226
+ enabled : true ,
227
+ class : undefined ,
228
+ run : ( ) => {
229
+ disableHint ( ) ;
230
+ }
231
+ }
232
+ ] ;
233
+ }
234
+ } ) ;
206
235
}
207
236
208
237
private _getHintInlineChat ( providers : IChatAgent [ ] ) {
@@ -244,7 +273,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
244
273
const hintPart = $ ( 'a' , undefined , fragment ) ;
245
274
hintPart . style . fontStyle = 'italic' ;
246
275
hintPart . style . cursor = 'pointer' ;
247
- this . toDispose . add ( dom . addDisposableListener ( hintPart , dom . EventType . CONTEXT_MENU , ( ) => this . _disableHint ( ) ) ) ;
276
+ this . toDispose . add ( dom . addDisposableListener ( hintPart , dom . EventType . CONTEXT_MENU , ( e ) => this . _disableHint ( e ) ) ) ;
248
277
this . toDispose . add ( dom . addDisposableListener ( hintPart , dom . EventType . CLICK , handleClick ) ) ;
249
278
return hintPart ;
250
279
} else {
@@ -263,7 +292,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
263
292
264
293
if ( this . options . clickable ) {
265
294
label . element . style . cursor = 'pointer' ;
266
- this . toDispose . add ( dom . addDisposableListener ( label . element , dom . EventType . CONTEXT_MENU , ( ) => this . _disableHint ( ) ) ) ;
295
+ this . toDispose . add ( dom . addDisposableListener ( label . element , dom . EventType . CONTEXT_MENU , ( e ) => this . _disableHint ( e ) ) ) ;
267
296
this . toDispose . add ( dom . addDisposableListener ( label . element , dom . EventType . CLICK , handleClick ) ) ;
268
297
}
269
298
0 commit comments