Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only semantically highlight documents from uri.scheme 'file' #5059

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/features/semanticTokensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,18 @@ export default class SemanticTokensProvider extends AbstractProvider implements
}

async _provideSemanticTokens(document: vscode.TextDocument, range: protocol.V2.Range, token: vscode.CancellationToken): Promise<vscode.SemanticTokens | null> {
// We can only semantically highlight file from disk.
if (document.uri.scheme !== "file") {
return null;
}

const options = this.optionProvider.GetLatestOptions();
if (!options.useSemanticHighlighting) {
return null;
}

let req = createRequest<protocol.V2.SemanticHighlightRequest>(document, new vscode.Position(0, 0));
req.Range = range;
// We need to include the document contents in our request for cases where we are highlighting
// a version of the document other than the current version, such as in the Diff view.
req.VersionedText = document.getText();

const versionBeforeRequest = document.version;

Expand Down