Procházet zdrojové kódy

Ignore validation requests for disposed models

Alex Dima před 8 roky
rodič
revize
f3f3e04ad2
1 změnil soubory, kde provedl 8 přidání a 0 odebrání
  1. 8 0
      src/languageFeatures.ts

+ 8 - 0
src/languageFeatures.ts

@@ -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));