Skip to content

Commit

Permalink
Fixes #178461: Only fetch semantic tokens for visible documents
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Apr 6, 2023
1 parent efd550c commit d4c8b9a
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -126,6 +126,11 @@ class ModelSemanticColoring extends Disposable {
this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
}
}));
this._register(this._model.onDidChangeAttached(() => {
if (!this._fetchDocumentSemanticTokens.isScheduled()) {
this._fetchDocumentSemanticTokens.schedule(this._debounceInformation.get(this._model));
}
}));
this._register(this._model.onDidChangeLanguage(() => {
// clear any outstanding state
if (this._currentDocumentResponse) {
Expand Down Expand Up @@ -201,6 +206,11 @@ class ModelSemanticColoring extends Disposable {
return;
}

if (!this._model.isAttachedToEditor()) {
// this document is not visible, there is no need to fetch semantic tokens for it
return;
}

const cancellationTokenSource = new CancellationTokenSource();
const lastProvider = this._currentDocumentResponse ? this._currentDocumentResponse.provider : null;
const lastResultId = this._currentDocumentResponse ? this._currentDocumentResponse.resultId || null : null;
Expand Down

0 comments on commit d4c8b9a

Please sign in to comment.