未验证 提交 59a81918 编写于 作者: A Alex Dima

Handle case where the text model is disposed while semantic tokens computation takes place

上级 5eaf74f5
......@@ -455,6 +455,7 @@ class SemanticColoringFeature extends Disposable {
class ModelSemanticColoring extends Disposable {
private _isDisposed: boolean;
private readonly _model: ITextModel;
private readonly _fetchSemanticTokens: RunOnceScheduler;
private _currentResponse: SemanticColoring | null;
......@@ -463,6 +464,7 @@ class ModelSemanticColoring extends Disposable {
constructor(model: ITextModel) {
super();
this._isDisposed = false;
this._model = model;
this._fetchSemanticTokens = this._register(new RunOnceScheduler(() => this._fetchSemanticTokensNow(), 500));
this._currentResponse = null;
......@@ -474,6 +476,7 @@ class ModelSemanticColoring extends Disposable {
}
public dispose(): void {
this._isDisposed = true;
if (this._currentResponse) {
this._currentResponse.dispose();
this._currentResponse = null;
......@@ -513,6 +516,13 @@ class ModelSemanticColoring extends Disposable {
this._currentResponse.dispose();
this._currentResponse = null;
}
if (this._isDisposed) {
// disposed!
if (tokens) {
tokens.dispose();
}
return;
}
this._currentResponse = tokens;
if (!this._currentResponse) {
this._model.setSemanticTokens(null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册