@@ -29,6 +29,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
2929import { IEditorProgressService } from 'vs/platform/progress/common/progress' ;
3030import { CodeActionModel , CodeActionsState , SUPPORTED_CODE_ACTIONS } from './codeActionModel' ;
3131import { CodeActionAutoApply , CodeActionCommandArgs , CodeActionFilter , CodeActionItem , CodeActionKind , CodeActionSet , CodeActionTrigger , CodeActionTriggerSource } from '../common/types' ;
32+ import { IdleValue } from 'vs/base/common/async' ;
3233
3334function contextKeyForSupportedActions ( kind : CodeActionKind ) {
3435 return ContextKeyExpr . regex (
@@ -92,7 +93,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
9293 }
9394
9495 private readonly _editor : ICodeEditor ;
95- private readonly _model : CodeActionModel ;
96+ private readonly _model : IdleValue < CodeActionModel > ;
9697 private readonly _ui : Lazy < CodeActionUi > ;
9798
9899 constructor (
@@ -106,8 +107,14 @@ export class CodeActionController extends Disposable implements IEditorContribut
106107 super ( ) ;
107108
108109 this . _editor = editor ;
109- this . _model = this . _register ( new CodeActionModel ( this . _editor , languageFeaturesService . codeActionProvider , markerService , contextKeyService , progressService ) ) ;
110- this . _register ( this . _model . onDidChangeState ( newState => this . update ( newState ) ) ) ;
110+
111+ this . _model = this . _register ( new IdleValue ( ( ) => {
112+ const model = this . _register ( new CodeActionModel ( this . _editor , languageFeaturesService . codeActionProvider , markerService , contextKeyService , progressService ) ) ;
113+
114+ this . _register ( model . onDidChangeState ( newState => this . update ( newState ) ) ) ;
115+
116+ return model ;
117+ } ) ) ;
111118
112119 this . _ui = new Lazy ( ( ) =>
113120 this . _register ( _instantiationService . createInstance ( CodeActionUi , editor , QuickFixAction . Id , AutoFixAction . Id , {
@@ -149,7 +156,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
149156 }
150157
151158 private _trigger ( trigger : CodeActionTrigger ) {
152- return this . _model . trigger ( trigger ) ;
159+ return this . _model . value . trigger ( trigger ) ;
153160 }
154161
155162 private _applyCodeAction ( action : CodeActionItem , preview : boolean ) : Promise < void > {
0 commit comments