mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +01:00
on model remove dispose listener, clear timeout, fixes #10
This commit is contained in:
parent
776e684da2
commit
3248b9469e
1 changed files with 13 additions and 2 deletions
|
|
@ -58,16 +58,27 @@ export class DiagnostcsAdapter extends Adapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
let handle: number;
|
let handle: number;
|
||||||
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
const changeSubscription = model.onDidChangeContent(() => {
|
||||||
clearTimeout(handle);
|
clearTimeout(handle);
|
||||||
handle = setTimeout(() => this._doValidate(model.uri), 500);
|
handle = setTimeout(() => this._doValidate(model.uri), 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._listener[model.uri.toString()] = {
|
||||||
|
dispose() {
|
||||||
|
changeSubscription.dispose();
|
||||||
|
clearTimeout(handle);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this._doValidate(model.uri);
|
this._doValidate(model.uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onModelRemoved = (model: monaco.editor.IModel): void => {
|
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));
|
this._disposables.push(monaco.editor.onDidCreateModel(onModelAdd));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue