@@ -29,6 +29,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
29
29
import { IEditorProgressService } from 'vs/platform/progress/common/progress' ;
30
30
import { CodeActionModel , CodeActionsState , SUPPORTED_CODE_ACTIONS } from './codeActionModel' ;
31
31
import { CodeActionAutoApply , CodeActionCommandArgs , CodeActionFilter , CodeActionItem , CodeActionKind , CodeActionSet , CodeActionTrigger , CodeActionTriggerSource } from '../common/types' ;
32
+ import { IdleValue } from 'vs/base/common/async' ;
32
33
33
34
function contextKeyForSupportedActions ( kind : CodeActionKind ) {
34
35
return ContextKeyExpr . regex (
@@ -92,7 +93,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
92
93
}
93
94
94
95
private readonly _editor : ICodeEditor ;
95
- private readonly _model : CodeActionModel ;
96
+ private readonly _model : IdleValue < CodeActionModel > ;
96
97
private readonly _ui : Lazy < CodeActionUi > ;
97
98
98
99
constructor (
@@ -106,8 +107,14 @@ export class CodeActionController extends Disposable implements IEditorContribut
106
107
super ( ) ;
107
108
108
109
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
+ } ) ) ;
111
118
112
119
this . _ui = new Lazy ( ( ) =>
113
120
this . _register ( _instantiationService . createInstance ( CodeActionUi , editor , QuickFixAction . Id , AutoFixAction . Id , {
@@ -149,7 +156,7 @@ export class CodeActionController extends Disposable implements IEditorContribut
149
156
}
150
157
151
158
private _trigger ( trigger : CodeActionTrigger ) {
152
- return this . _model . trigger ( trigger ) ;
159
+ return this . _model . value . trigger ( trigger ) ;
153
160
}
154
161
155
162
private _applyCodeAction ( action : CodeActionItem , preview : boolean ) : Promise < void > {
0 commit comments