mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-07 12:00:42 +00:00
Merge pull request #110 from patrickshipe/prevent-null-model-crash
Fix crashes from null model
This commit is contained in:
commit
7bf8137107
1 changed files with 3 additions and 1 deletions
|
|
@ -62,7 +62,9 @@ export function createDiagnosticsAdapter(
|
||||||
const diagnostics = await worker.doValidation(String(resource));
|
const diagnostics = await worker.doValidation(String(resource));
|
||||||
const markers = diagnostics.map(toDiagnostics);
|
const markers = diagnostics.map(toDiagnostics);
|
||||||
const model = editor.getModel(resource);
|
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);
|
editor.setModelMarkers(model, languageId, markers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue