Fix crashes from null model

This commit is contained in:
Patrick Shipe 2021-09-15 08:59:40 -06:00
parent 8d278d3d19
commit 2bece31f56

View file

@ -62,7 +62,9 @@ export function createDiagnosticsAdapter(
const diagnostics = await worker.doValidation(String(resource));
const markers = diagnostics.map(toDiagnostics);
const model = editor.getModel(resource);
if (model.getModeId() === languageId) {
// Return value from getModel can be null if model not found
// (e.g. if user navigates away from editor)
if (model && model.getModeId() === languageId) {
editor.setModelMarkers(model, languageId, markers);
}
};