Skip to content

Commit

Permalink
Send document buffer when semantically highlighting old document vers…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
JoeRobich committed Nov 30, 2021
1 parent 8d8e9cc commit 90f1e3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@
},
"csharp.semanticHighlighting.enabled": {
"type": "boolean",
"default": false,
"default": true,
"description": "Enable/disable Semantic Highlighting for C# files (Razor files currently unsupported). Defaults to false. Close open files for changes to take effect.",
"scope": "window"
},
Expand Down Expand Up @@ -3820,4 +3820,4 @@
}
]
}
}
}
6 changes: 5 additions & 1 deletion src/features/semanticTokensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ export default class SemanticTokensProvider extends AbstractProvider implements
return null;
}

let req = createRequest<protocol.V2.SemanticHighlightRequest>(document, new vscode.Position(0, 0));
const currentDocument = vscode.workspace.textDocuments.find(d => d.fileName === document.fileName);
const isCurrentVersion = currentDocument?.version === document.version;

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

const versionBeforeRequest = document.version;
Expand Down

0 comments on commit 90f1e3b

Please sign in to comment.