Fix potential NPE

This commit is contained in:
Alexandru Dima 2020-12-23 14:32:45 +01:00
parent bdd3de5f00
commit f1754a3b26
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0

View file

@ -104,7 +104,10 @@ export class DiagnosticsAdapter {
.then((worker) => { .then((worker) => {
return worker.doValidation(resource.toString()).then((diagnostics) => { return worker.doValidation(resource.toString()).then((diagnostics) => {
const markers = diagnostics.map((d) => toDiagnostics(resource, d)); const markers = diagnostics.map((d) => toDiagnostics(resource, d));
editor.setModelMarkers(editor.getModel(resource), languageId, markers); const model = editor.getModel(resource);
if (model && model.getModeId() === languageId) {
editor.setModelMarkers(model, languageId, markers);
}
}); });
}) })
.then(undefined, (err) => { .then(undefined, (err) => {