mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 17:25:39 +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;
|
||||
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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue