From 88c91d2126ffe14f9eb56cf6a4d21206bb099f3d Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sat, 17 Dec 2022 16:03:21 -0700 Subject: [PATCH] Fix error when model already exists --- web/src/routes/Config.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/src/routes/Config.jsx b/web/src/routes/Config.jsx index 66c3d6117..678619301 100644 --- a/web/src/routes/Config.jsx +++ b/web/src/routes/Config.jsx @@ -50,6 +50,13 @@ export default function Config() { const modelUri = Uri.parse('a://b/api/config/schema.json'); + let yamlModel; + if (editor.getModels().length > 0) { + yamlModel = editor.getModel(modelUri) + } else { + yamlModel = editor.createModel(config, 'yaml', modelUri) + } + setDiagnosticsOptions({ enableSchemaRequest: true, hover: true, @@ -66,7 +73,7 @@ export default function Config() { window.editor = editor.create(document.getElementById('container'), { language: 'yaml', - model: editor.createModel(config, 'yaml', modelUri), + model: yamlModel, scrollBeyondLastLine: false, theme: 'vs-dark', });