Skip to content

Commit 8294940

Browse files
authored
Make CodeActionModel an idleValue (microsoft#166053)
For microsoft#164171
1 parent 4f30fd5 commit 8294940

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers';
2929
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
3030
import { CodeActionModel, CodeActionsState, SUPPORTED_CODE_ACTIONS } from './codeActionModel';
3131
import { CodeActionAutoApply, CodeActionCommandArgs, CodeActionFilter, CodeActionItem, CodeActionKind, CodeActionSet, CodeActionTrigger, CodeActionTriggerSource } from '../common/types';
32+
import { IdleValue } from 'vs/base/common/async';
3233

3334
function 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

Comments
 (0)