diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-15 16:35:23 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-15 16:35:23 +0000 |
commit | 4e24b25c669965cf6a68c4b8e775cc83615d978a (patch) | |
tree | 7d44ca9749add5146d0672192d14df9de6c2e730 /editors | |
parent | 4c1b2b921866279d014e377b958112b9e53edc52 (diff) | |
parent | 6fba427bf35bebdc7aa08a241ecbe83a2f725127 (diff) |
Merge #2565
2565: Fixed syntax highlighting not refreshing on windows. r=matklad a=omerbenamram
I was encoutering the same probelm described in #1690.
It seems that events initiated by the frontend with `rust-analyzer/decorationsRequest` would go through.
So whenever a user switches tabs, highlighting will update.
However, when decorations are initiated by a notification with `rust-analyzer/publishDecorations`, it would fail on this check here https://github.com/rust-analyzer/rust-analyzer/blob/6cbd8a4a4bbca8a7656df9f3ef849acebbf9ef9b/editors/code/src/notifications/publish_decorations.ts#L15 (`targetEditor` will always be `undefined`).
This is because it's trying to match the uri `rust-analyzer` sends (which uses an uppercase drive letter) to the uri provided at `editor.document.uri.toString()`, which is both escaped (uses `%3a` for `:`), and uses a lowercase letter drive.
Aparrently this was an issue for some other extensions aswell - https://github.com/Microsoft/vscode/issues/68325.
But this is the defined behavior - https://github.com/microsoft/vscode/blob/c110d84460b3e45842a8fe753562341003595e1d/src/vs/vscode.d.ts#L1304
This fix is only relevant for windows.
I've opted for a server-side fix, since rust will always return uppercase letters for drives, there seems to be no other easy solution than manipulating the Url string before sending it to the frontend.
Closes #1690.
Co-authored-by: Omer Ben-Amram <[email protected]>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/src/notifications/publish_decorations.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/editors/code/src/notifications/publish_decorations.ts b/editors/code/src/notifications/publish_decorations.ts index 00ffb7776..f23e286ad 100644 --- a/editors/code/src/notifications/publish_decorations.ts +++ b/editors/code/src/notifications/publish_decorations.ts | |||
@@ -9,11 +9,16 @@ export interface PublishDecorationsParams { | |||
9 | } | 9 | } |
10 | 10 | ||
11 | export function handle(params: PublishDecorationsParams) { | 11 | export function handle(params: PublishDecorationsParams) { |
12 | const targetEditor = vscode.window.visibleTextEditors.find( | 12 | const targetEditor = vscode.window.visibleTextEditors.find(editor => { |
13 | editor => editor.document.uri.toString() === params.uri, | 13 | const unescapedUri = unescape(editor.document.uri.toString()); |
14 | ); | 14 | // Unescaped URI looks like: |
15 | // file:///c:/Workspace/ra-test/src/main.rs | ||
16 | return unescapedUri === params.uri; | ||
17 | }); | ||
18 | |||
15 | if (!Server.config.highlightingOn || !targetEditor) { | 19 | if (!Server.config.highlightingOn || !targetEditor) { |
16 | return; | 20 | return; |
17 | } | 21 | } |
22 | |||
18 | Server.highlighter.setHighlights(targetEditor, params.decorations); | 23 | Server.highlighter.setHighlights(targetEditor, params.decorations); |
19 | } | 24 | } |