about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2022-08-16 11:24:50 +0300
committerLaurențiu Nicola <lnicola@dend.ro>2022-08-16 11:24:50 +0300
commit8231fee466a7a288a3b506a5fdf0ab057b2acbeb (patch)
tree0db7242fa1f7e5aac42a3156d047e71f07cab731 /editors/code/src
parent22c8c9c4014c63309524f218d92554ebfdf9621e (diff)
downloadrust-8231fee466a7a288a3b506a5fdf0ab057b2acbeb.tar.gz
rust-8231fee466a7a288a3b506a5fdf0ab057b2acbeb.zip
:arrow_up: rust-analyzer
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/client.ts16
-rw-r--r--editors/code/src/commands.ts18
2 files changed, 32 insertions, 2 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 8a2dea6b35b..27ab31db8db 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -105,6 +105,22 @@ export async function createClient(
         traceOutputChannel: traceOutputChannel(),
         outputChannel: outputChannel(),
         middleware: {
+            async handleDiagnostics(uri, diagnostics, next) {
+                // Workaround for https://github.com/microsoft/vscode/issues/155531
+                for (const diagnostic of diagnostics) {
+                    if (!diagnostic.message) {
+                        diagnostic.message = " ";
+                    }
+                    if (diagnostic.relatedInformation) {
+                        for (const relatedInformation of diagnostic.relatedInformation) {
+                            if (!relatedInformation.message) {
+                                relatedInformation.message = " ";
+                            }
+                        }
+                    }
+                }
+                next(uri, diagnostics);
+            },
             async provideHover(
                 document: vscode.TextDocument,
                 position: vscode.Position,
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index bf55329ca1f..1b793bb0b15 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -326,8 +326,22 @@ export function toggleInlayHints(_ctx: Ctx): Cmd {
         const config = vscode.workspace.getConfiguration("editor.inlayHints", {
             languageId: "rust",
         });
-        const value = !config.get("enabled");
-        await config.update("enabled", value, vscode.ConfigurationTarget.Global);
+
+        const value = config.get("enabled");
+        let stringValue;
+        if (typeof value === "string") {
+            stringValue = value;
+        } else {
+            stringValue = value ? "on" : "off";
+        }
+        const nextValues: Record<string, string> = {
+            on: "off",
+            off: "on",
+            onUnlessPressed: "offUnlessPressed",
+            offUnlessPressed: "onUnlessPressed",
+        };
+        const nextValue = nextValues[stringValue] ?? "on";
+        await config.update("enabled", nextValue, vscode.ConfigurationTarget.Global);
     };
 }