Author: Ilya Biryukov Date: 2019-11-11T09:21:25+01:00 New Revision: b4f46a9bb42972e663f8b7b4d15e4c8ed3fecef4
URL: https://github.com/llvm/llvm-project/commit/b4f46a9bb42972e663f8b7b4d15e4c8ed3fecef4 DIFF: https://github.com/llvm/llvm-project/commit/b4f46a9bb42972e663f8b7b4d15e4c8ed3fecef4.diff LOG: [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 Added: Modified: clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json clang-tools-extra/clangd/clients/clangd-vscode/package.json clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json index 0b59b2ffcc05..bbff586bbdca 100644 --- a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json +++ b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json @@ -1,6 +1,6 @@ { "name": "vscode-clangd", - "version": "0.0.18", + "version": "0.0.19", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json b/clang-tools-extra/clangd/clients/clangd-vscode/package.json index 03de7b3e58b0..05aafeb5f850 100644 --- a/clang-tools-extra/clangd/clients/clangd-vscode/package.json +++ b/clang-tools-extra/clangd/clients/clangd-vscode/package.json @@ -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": { diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts index 930079b1b2da..17517441bab9 100644 --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts @@ -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) => { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits