Skip to content

Commit

Permalink
on model remove dispose listener, clear timeout, fixes microsoft#10
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Aug 26, 2016
1 parent 776e684 commit 3248b94
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/languageFeatures.ts
Expand Up @@ -58,16 +58,27 @@ export class DiagnostcsAdapter extends Adapter {
}

let handle: number;
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
const changeSubscription = model.onDidChangeContent(() => {
clearTimeout(handle);
handle = setTimeout(() => this._doValidate(model.uri), 500);
});

this._listener[model.uri.toString()] = {
dispose() {
changeSubscription.dispose();
clearTimeout(handle);
}
};

this._doValidate(model.uri);
};

const onModelRemoved = (model: monaco.editor.IModel): void => {
delete this._listener[model.uri.toString()];
const key = model.uri.toString();
if (this._listener[key]) {
this._listener[key].dispose();
delete this._listener[key];
}
};

this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
Expand Down

0 comments on commit 3248b94

Please sign in to comment.