mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-05 15:42:24 +00:00
[clangd] Fixes colon escaping on Windows
vscode always escapes the colon on the file uri, which causes the semantic highlighting fails on windows. fixes: https://github.com/clangd/clangd/issues/176
This commit is contained in:
parent
2f4fb200b6
commit
b4f46a9bb4
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vscode-clangd",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "vscode-clangd",
|
||||
"displayName": "vscode-clangd",
|
||||
"description": "Clang Language Server",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"publisher": "llvm-vs-code-extensions",
|
||||
"homepage": "https://clang.llvm.org/extra/clangd.html",
|
||||
"engines": {
|
||||
|
@ -114,17 +114,17 @@ export class SemanticHighlightingFeature implements vscodelc.StaticFeature {
|
||||
this.loadCurrentTheme();
|
||||
// Event handling for handling with TextDocuments/Editors lifetimes.
|
||||
this.subscriptions.push(vscode.window.onDidChangeVisibleTextEditors(
|
||||
(editors: vscode.TextEditor[]) =>
|
||||
editors.forEach((e) => this.highlighter.applyHighlights(
|
||||
e.document.uri.toString()))));
|
||||
(editors: vscode.TextEditor[]) => editors.forEach(
|
||||
(e) => this.highlighter.applyHighlights(e.document.uri))));
|
||||
this.subscriptions.push(vscode.workspace.onDidCloseTextDocument(
|
||||
(doc) => this.highlighter.removeFileHighlightings(doc.uri.toString())));
|
||||
(doc) => this.highlighter.removeFileHighlightings(doc.uri)));
|
||||
}
|
||||
|
||||
handleNotification(params: SemanticHighlightingParams) {
|
||||
const lines: SemanticHighlightingLine[] = params.lines.map(
|
||||
(line) => ({line : line.line, tokens : decodeTokens(line.tokens)}));
|
||||
this.highlighter.highlight(params.textDocument.uri, lines);
|
||||
this.highlighter.highlight(vscode.Uri.parse(params.textDocument.uri),
|
||||
lines);
|
||||
}
|
||||
// Disposes of all disposable resources used by this object.
|
||||
public dispose() {
|
||||
@ -199,19 +199,21 @@ export class Highlighter {
|
||||
// Adds incremental highlightings to the current highlightings for the file
|
||||
// with fileUri. Also applies the highlightings to any associated
|
||||
// TextEditor(s).
|
||||
public highlight(fileUri: string,
|
||||
public highlight(fileUri: vscode.Uri,
|
||||
highlightingLines: SemanticHighlightingLine[]) {
|
||||
if (!this.files.has(fileUri)) {
|
||||
this.files.set(fileUri, new Map());
|
||||
const fileUriStr = fileUri.toString();
|
||||
if (!this.files.has(fileUriStr)) {
|
||||
this.files.set(fileUriStr, new Map());
|
||||
}
|
||||
const fileHighlightings = this.files.get(fileUri);
|
||||
const fileHighlightings = this.files.get(fileUriStr);
|
||||
highlightingLines.forEach((line) => fileHighlightings.set(line.line, line));
|
||||
this.applyHighlights(fileUri);
|
||||
}
|
||||
|
||||
// Applies all the highlightings currently stored for a file with fileUri.
|
||||
public applyHighlights(fileUri: string) {
|
||||
if (!this.files.has(fileUri))
|
||||
public applyHighlights(fileUri: vscode.Uri) {
|
||||
const fileUriStr = fileUri.toString();
|
||||
if (!this.files.has(fileUriStr))
|
||||
// There are no highlightings for this file, must return early or will get
|
||||
// out of bounds when applying the decorations below.
|
||||
return;
|
||||
@ -224,7 +226,7 @@ export class Highlighter {
|
||||
// TextEditorDecorationType is used per scope.
|
||||
const ranges = this.getDecorationRanges(fileUri);
|
||||
vscode.window.visibleTextEditors.forEach((e) => {
|
||||
if (e.document.uri.toString() !== fileUri)
|
||||
if (e.document.uri.toString() !== fileUriStr)
|
||||
return;
|
||||
this.decorationTypes.forEach((d, i) => e.setDecorations(d, ranges[i]));
|
||||
});
|
||||
@ -232,27 +234,27 @@ export class Highlighter {
|
||||
|
||||
// Called when a text document is closed. Removes any highlighting entries for
|
||||
// the text document that was closed.
|
||||
public removeFileHighlightings(fileUri: string) {
|
||||
public removeFileHighlightings(fileUri: vscode.Uri) {
|
||||
// If there exists no entry the call to delete just returns false.
|
||||
this.files.delete(fileUri);
|
||||
this.files.delete(fileUri.toString());
|
||||
}
|
||||
|
||||
// Gets the uris as strings for the currently visible text editors.
|
||||
protected getVisibleTextEditorUris(): string[] {
|
||||
return vscode.window.visibleTextEditors.map((e) =>
|
||||
e.document.uri.toString());
|
||||
protected getVisibleTextEditorUris(): vscode.Uri[] {
|
||||
return vscode.window.visibleTextEditors.map((e) => e.document.uri);
|
||||
}
|
||||
|
||||
// Returns the ranges that should be used when decorating. Index i in the
|
||||
// range array has the decoration type at index i of this.decorationTypes.
|
||||
protected getDecorationRanges(fileUri: string): vscode.Range[][] {
|
||||
if (!this.files.has(fileUri))
|
||||
protected getDecorationRanges(fileUri: vscode.Uri): vscode.Range[][] {
|
||||
const fileUriStr = fileUri.toString();
|
||||
if (!this.files.has(fileUriStr))
|
||||
// this.files should always have an entry for fileUri if we are here. But
|
||||
// if there isn't one we don't want to crash the extension. This is also
|
||||
// useful for tests.
|
||||
return [];
|
||||
const lines: SemanticHighlightingLine[] =
|
||||
Array.from(this.files.get(fileUri).values());
|
||||
Array.from(this.files.get(fileUriStr).values());
|
||||
const decorations: vscode.Range[][] = this.decorationTypes.map(() => []);
|
||||
lines.forEach((line) => {
|
||||
line.tokens.forEach((token) => {
|
||||
|
Loading…
Reference in New Issue
Block a user