Skip to content

Commit 90f1e3b

Browse files
committed
Send document buffer when semantically highlighting old document versions
1 parent 8d8e9cc commit 90f1e3b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@
724724
},
725725
"csharp.semanticHighlighting.enabled": {
726726
"type": "boolean",
727-
"default": false,
727+
"default": true,
728728
"description": "Enable/disable Semantic Highlighting for C# files (Razor files currently unsupported). Defaults to false. Close open files for changes to take effect.",
729729
"scope": "window"
730730
},
@@ -3820,4 +3820,4 @@
38203820
}
38213821
]
38223822
}
3823-
}
3823+
}

src/features/semanticTokensProvider.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ export default class SemanticTokensProvider extends AbstractProvider implements
187187
return null;
188188
}
189189

190-
let req = createRequest<protocol.V2.SemanticHighlightRequest>(document, new vscode.Position(0, 0));
190+
const currentDocument = vscode.workspace.textDocuments.find(d => d.fileName === document.fileName);
191+
const isCurrentVersion = currentDocument?.version === document.version;
192+
193+
// 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.
194+
let req = createRequest<protocol.V2.SemanticHighlightRequest>(document, new vscode.Position(0, 0), /* includeBuffer: */ !isCurrentVersion);
191195
req.Range = range;
192196

193197
const versionBeforeRequest = document.version;

0 commit comments

Comments
 (0)