Dispose the old model before switching in demo

This prevents errors.
This commit is contained in:
Remco Haszing 2021-09-17 16:02:53 +02:00
parent 979ed62d6f
commit 3a0b164c51
No known key found for this signature in database
GPG key ID: 40D9F5FE9155FD3C

View file

@ -152,7 +152,10 @@ fetch('https://www.schemastore.org/api/json/catalog.json').then(async (response)
});
select.addEventListener('change', () => {
ed.setModel(editor.createModel(ed.getValue(), 'yaml', Uri.parse(select.value)));
const oldModel = ed.getModel();
const newModel = editor.createModel(oldModel.getValue(), 'yaml', Uri.parse(select.value));
ed.setModel(newModel);
oldModel.dispose();
});
function* iterateSymbols(