Skip to content

Commit 329dc37

Browse files
committed
Fix updating options when editor hasn't loaded yet
1 parent eb44ed5 commit 329dc37

File tree

1 file changed

+6
-4
lines changed
  • packages/app/src/app/overmind/effects/vscode

1 file changed

+6
-4
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ export class VSCodeEffect {
250250
}
251251

252252
public updateOptions(options: { readOnly: boolean }) {
253-
this.editorApi.getActiveCodeEditor().updateOptions(options);
253+
const editor = this.editorApi.getActiveCodeEditor();
254+
255+
if (editor) {
256+
editor.updateOptions(options);
257+
}
254258
}
255259

256260
public updateUserSelections(userSelections: EditorSelection[]) {
@@ -267,9 +271,7 @@ export class VSCodeEffect {
267271
public setReadOnly(enabled: boolean) {
268272
this.readOnly = enabled;
269273

270-
const activeEditor = this.editorApi.getActiveCodeEditor();
271-
272-
activeEditor.updateOptions({ readOnly: enabled });
274+
this.updateOptions({ readOnly: enabled });
273275
}
274276

275277
public updateLayout = (width: number, height: number) => {

0 commit comments

Comments
 (0)