directly resolving the code action when it is an ai code action

This commit is contained in:
Aiday Marlen Kyzy 2023-11-17 17:09:15 +01:00
parent 4d4bcb9b34
commit ee8bb3475b
No known key found for this signature in database
GPG key ID: 24A8B53DBD26FF4E
2 changed files with 9 additions and 0 deletions

View file

@ -260,6 +260,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
return;
}
// place into the lightBulbWidget file, will need to define the icon there
console.log('actionsToShow : ', actionsToShow);
let lightbulbMode = LightBulbMenuIconMode.Standard;
actionsToShow.forEach(action => {
@ -272,6 +273,13 @@ export class CodeActionController extends Disposable implements IEditorContribut
});
console.log('lightbulbMode : ', lightbulbMode);
this._lightBulbWidget.rawValue?.updateLightBulbTitleAndIcon(lightbulbMode);
//
if (actionsToShow.length === 1 && actionsToShow[0].action.isAI) {
// There is exactly one code action and it is an AI code action, then automatically trigger it
actionsToShow[0].resolve(CancellationToken.None);
return;
}
const anchor = Position.isIPosition(at) ? this.toCoords(at) : at;

View file

@ -213,6 +213,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
this.updateLightBulbTitleAndIcon();
}
// make private once again, because we can find the actions directly from this file, do not need to trigger this method from someplace else
public updateLightBulbTitleAndIcon(iconMode: LightBulbMenuIconMode = LightBulbMenuIconMode.Standard): void {
if (iconMode !== LightBulbMenuIconMode.Standard) {