]> git.lizzy.rs Git - rust.git/commitdiff
Insert a ZWNJ before type hints
authorLaurențiu Nicola <lnicola@dend.ro>
Thu, 15 Oct 2020 07:29:30 +0000 (10:29 +0300)
committerLaurențiu Nicola <lnicola@dend.ro>
Thu, 15 Oct 2020 07:56:28 +0000 (10:56 +0300)
editors/code/src/inlay_hints.ts

index 30ade9b986c6f59715acf7633fa0266380288f5e..ed0db292450b9e6e7f640858989b08725d7d8250 100644 (file)
@@ -44,10 +44,12 @@ const paramHints = createHintStyle("parameter");
 const chainingHints = createHintStyle("chaining");
 
 function createHintStyle(hintKind: "type" | "parameter" | "chaining") {
+    // U+200C is a zero-width non-joiner to prevent the editor from forming a ligature
+    // between code and type hints
     const [pos, render] = ({
-        type: ["after", (label: string) => `: ${label}`],
+        type: ["after", (label: string) => `\u{200c}: ${label}`],
         parameter: ["before", (label: string) => `${label}: `],
-        chaining: ["after", (label: string) => `: ${label}`],
+        chaining: ["after", (label: string) => `\u{200c}: ${label}`],
     } as const)[hintKind];
 
     const fg = new vscode.ThemeColor(`rust_analyzer.inlayHints.foreground.${hintKind}Hints`);