about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2023-01-03 12:32:38 +0100
committerLukas Wirth <lukastw97@gmail.com>2023-01-03 12:32:38 +0100
commitc4d8cf1dad9e2ad5710c56533c42979e91520c78 (patch)
tree536739fe47a20d4011cee9d6782ca761530d4d0f
parent50801b7d6a5c18d24ae47e5a8963431899da20cd (diff)
downloadrust-c4d8cf1dad9e2ad5710c56533c42979e91520c78.tar.gz
rust-c4d8cf1dad9e2ad5710c56533c42979e91520c78.zip
Use ZWNJ to prevent VSCode from forming ligatures between hints and code
-rw-r--r--editors/code/src/client.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 1470c1f581d..e6595340aae 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -100,6 +100,24 @@ export async function createClient(
                     }
                 },
             },
+            async provideInlayHints(document, viewPort, token, next) {
+                const inlays = await next(document, viewPort, token);
+                if (!inlays) {
+                    return inlays;
+                }
+                // U+200C is a zero-width non-joiner to prevent the editor from forming a ligature
+                // between code and hints
+                for (const inlay of inlays) {
+                    if (typeof inlay.label === "string") {
+                        inlay.label = `\u{200c}${inlay.label}\u{200c}`;
+                    } else if (Array.isArray(inlay.label)) {
+                        for (const it of inlay.label) {
+                            it.value = `\u{200c}${it.value}\u{200c}`;
+                        }
+                    }
+                }
+                return inlays;
+            },
             async handleDiagnostics(
                 uri: vscode.Uri,
                 diagnostics: vscode.Diagnostic[],