]> git.lizzy.rs Git - rust.git/blob - editors/code/src/notifications/publish_decorations.ts
make drive comparison case-insensitive.
[rust.git] / editors / code / src / notifications / publish_decorations.ts
1 import * as vscode from 'vscode';
2
3 import { Decoration } from '../highlighting';
4 import { Server } from '../server';
5
6 export interface PublishDecorationsParams {
7     uri: string;
8     decorations: Decoration[];
9 }
10
11 export function handle(params: PublishDecorationsParams) {
12     const targetEditor = vscode.window.visibleTextEditors.find(
13         editor => {
14             const unescapedUri = unescape(editor.document.uri.toString());
15             // Unescaped URI should be something like:
16             // file:///c:/Workspace/ra-test/src/main.rs
17             // RA server might send it with the drive letter uppercased, so we force only the drive letter to lowercase.
18             const uriWithLowercasedDrive = params.uri.substr(0, 8) + params.uri[8].toLowerCase() + params.uri.substr(9);
19             return unescapedUri === uriWithLowercasedDrive
20         }
21     );
22
23     if (!Server.config.highlightingOn || !targetEditor) {
24         return;
25     }
26
27     Server.highlighter.setHighlights(targetEditor, params.decorations);
28 }