@@ -88,7 +88,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
88
88
this . _lightBulbWidget = new Lazy ( ( ) => {
89
89
const widget = this . _editor . getContribution < LightBulbWidget > ( LightBulbWidget . ID ) ;
90
90
if ( widget ) {
91
- this . _register ( widget . onClick ( e => this . showCodeActionList ( e . actions , e , { includeDisabledActions : false , fromLightbulb : true } ) ) ) ;
91
+ this . _register ( widget . onClick ( e => this . showCodeActionsFromLightbulb ( e . actions , e ) ) ) ;
92
92
}
93
93
return widget ;
94
94
} ) ;
@@ -103,6 +103,21 @@ export class CodeActionController extends Disposable implements IEditorContribut
103
103
super . dispose ( ) ;
104
104
}
105
105
106
+ private async showCodeActionsFromLightbulb ( actions : CodeActionSet , at : IAnchor | IPosition ) : Promise < void > {
107
+ if ( actions . allAIFixes && actions . validActions . length === 1 ) {
108
+ const actionItem = actions . validActions [ 0 ] ;
109
+ const command = actionItem . action . command ;
110
+ if ( command && command . id === 'inlineChat.start' ) {
111
+ if ( command . arguments && command . arguments . length >= 1 ) {
112
+ command . arguments [ 0 ] = { ...command . arguments [ 0 ] , autoSend : false } ;
113
+ }
114
+ }
115
+ await this . _applyCodeAction ( actionItem , false , false , ApplyCodeActionReason . FromAILightbulb ) ;
116
+ return ;
117
+ }
118
+ await this . showCodeActionList ( actions , at , { includeDisabledActions : false , fromLightbulb : true } ) ;
119
+ }
120
+
106
121
public showCodeActions ( _trigger : CodeActionTrigger , actions : CodeActionSet , at : IAnchor | IPosition ) {
107
122
return this . showCodeActionList ( actions , at , { includeDisabledActions : false , fromLightbulb : false } ) ;
108
123
}
@@ -130,9 +145,9 @@ export class CodeActionController extends Disposable implements IEditorContribut
130
145
return this . _model . trigger ( trigger ) ;
131
146
}
132
147
133
- private async _applyCodeAction ( action : CodeActionItem , retrigger : boolean , preview : boolean ) : Promise < void > {
148
+ private async _applyCodeAction ( action : CodeActionItem , retrigger : boolean , preview : boolean , actionReason : ApplyCodeActionReason ) : Promise < void > {
134
149
try {
135
- await this . _instantiationService . invokeFunction ( applyCodeAction , action , ApplyCodeActionReason . FromCodeActions , { preview, editor : this . _editor } ) ;
150
+ await this . _instantiationService . invokeFunction ( applyCodeAction , action , actionReason , { preview, editor : this . _editor } ) ;
136
151
} finally {
137
152
if ( retrigger ) {
138
153
this . _trigger ( { type : CodeActionTriggerType . Auto , triggerAction : CodeActionTriggerSource . QuickFix , filter : { } } ) ;
@@ -172,7 +187,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
172
187
if ( validActionToApply ) {
173
188
try {
174
189
this . _lightBulbWidget . value ?. hide ( ) ;
175
- await this . _applyCodeAction ( validActionToApply , false , false ) ;
190
+ await this . _applyCodeAction ( validActionToApply , false , false , ApplyCodeActionReason . FromCodeActions ) ;
176
191
} finally {
177
192
actions . dispose ( ) ;
178
193
}
@@ -264,7 +279,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
264
279
265
280
const delegate : IActionListDelegate < CodeActionItem > = {
266
281
onSelect : async ( action : CodeActionItem , preview ?: boolean ) => {
267
- this . _applyCodeAction ( action , /* retrigger */ true , ! ! preview ) ;
282
+ this . _applyCodeAction ( action , /* retrigger */ true , ! ! preview , ApplyCodeActionReason . FromCodeActions ) ;
268
283
this . _actionWidgetService . hide ( ) ;
269
284
currentDecorations . clear ( ) ;
270
285
} ,
0 commit comments