44 *--------------------------------------------------------------------------------------------*/
55
66import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
7- import { Disposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
7+ import { Disposable } from 'vs/base/common/lifecycle' ;
88import { escapeRegExpCharacters } from 'vs/base/common/strings' ;
99import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
1010import { EditorAction , EditorCommand , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
@@ -26,7 +26,6 @@ import { CodeActionWidget } from './codeActionWidget';
2626import { LightBulbWidget } from './lightBulbWidget' ;
2727import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
2828import { onUnexpectedError } from 'vs/base/common/errors' ;
29- import { CodeActionSet } from 'vs/editor/contrib/codeAction/codeAction' ;
3029
3130function contextKeyForSupportedActions ( kind : CodeActionKind ) {
3231 return ContextKeyExpr . regex (
@@ -46,7 +45,6 @@ export class QuickFixController extends Disposable implements IEditorContributio
4645 private readonly _model : CodeActionModel ;
4746 private readonly _codeActionWidget : CodeActionWidget ;
4847 private readonly _lightBulbWidget : LightBulbWidget ;
49- private readonly _currentCodeActions = this . _register ( new MutableDisposable < CodeActionSet > ( ) ) ;
5048
5149 constructor (
5250 editor : ICodeEditor ,
@@ -81,29 +79,30 @@ export class QuickFixController extends Disposable implements IEditorContributio
8179 this . _register ( this . _keybindingService . onDidUpdateKeybindings ( this . _updateLightBulbTitle , this ) ) ;
8280 }
8381
84-
8582 private _onDidChangeCodeActionsState ( newState : CodeActionsState . State ) : void {
8683 if ( newState . type === CodeActionsState . Type . Triggered ) {
8784 newState . actions . then ( actions => {
88- this . _currentCodeActions . value = actions ;
89-
9085 if ( ! actions . actions . length && newState . trigger . context ) {
9186 MessageController . get ( this . _editor ) . showMessage ( newState . trigger . context . notAvailableMessage , newState . trigger . context . position ) ;
87+ actions . dispose ( ) ;
9288 }
9389 } ) ;
9490
9591 if ( newState . trigger . filter && newState . trigger . filter . kind ) {
9692 // Triggered for specific scope
97- newState . actions . then ( codeActions => {
93+ newState . actions . then ( async codeActions => {
9894 if ( codeActions . actions . length > 0 ) {
9995 // Apply if we only have one action or requested autoApply
10096 if ( newState . trigger . autoApply === CodeActionAutoApply . First || ( newState . trigger . autoApply === CodeActionAutoApply . IfSingle && codeActions . actions . length === 1 ) ) {
101- this . _applyCodeAction ( codeActions . actions [ 0 ] ) ;
97+ try {
98+ await this . _applyCodeAction ( codeActions . actions [ 0 ] ) ;
99+ } finally {
100+ codeActions . dispose ( ) ;
101+ }
102102 return ;
103103 }
104104 }
105105 this . _codeActionWidget . show ( newState . actions , newState . position ) ;
106-
107106 } ) . catch ( onUnexpectedError ) ;
108107 } else if ( newState . trigger . type === 'manual' ) {
109108 this . _codeActionWidget . show ( newState . actions , newState . position ) ;
@@ -118,7 +117,6 @@ export class QuickFixController extends Disposable implements IEditorContributio
118117 }
119118 }
120119 } else {
121- this . _currentCodeActions . clear ( ) ;
122120 this . _lightBulbWidget . hide ( ) ;
123121 }
124122 }
0 commit comments