Ignore validation requests for disposed models

This commit is contained in:
Alex Dima 2017-03-03 17:36:53 +01:00
parent ab02fc6402
commit f3f3e04ad2

View file

@ -115,6 +115,10 @@ export class DiagnostcsAdapter extends Adapter {
private _doValidate(resource: Uri): void {
this._worker(resource).then(worker => {
if (!monaco.editor.getModel(resource)) {
// model was disposed in the meantime
return null;
}
const promises: Promise<ts.Diagnostic[]>[] = [];
const {noSyntaxValidation, noSemanticValidation} = this._defaults.getDiagnosticsOptions();
if (!noSyntaxValidation) {
@ -125,6 +129,10 @@ export class DiagnostcsAdapter extends Adapter {
}
return Promise.join(promises);
}).then(diagnostics => {
if (!diagnostics || !monaco.editor.getModel(resource)) {
// model was disposed in the meantime
return null;
}
const markers = diagnostics
.reduce((p, c) => c.concat(p), [])
.map(d => this._convertDiagnostics(resource, d));