editor/sagas: fix error creating model on hot reload

This commit is contained in:
David Lechner
2022-05-18 17:47:29 -05:00
parent 325562996b
commit d02e38795b
+12 -5
View File
@@ -95,11 +95,18 @@ function* handleEditorOpenFile(
defined(didRead);
const model = monaco.editor.createModel(
didRead.contents,
pybricksMicroPythonId,
monaco.Uri.from({ scheme: 'pybricksCode', path: action.fileName }),
);
const modelUri = monaco.Uri.from({
scheme: 'pybricksCode',
path: action.fileName,
});
const model =
monaco.editor.getModel(modelUri) ??
monaco.editor.createModel(
didRead.contents,
pybricksMicroPythonId,
modelUri,
);
defer.push(() => model.dispose());
// TODO: get viewState from fileStorage