diff options
| author | bors <bors@rust-lang.org> | 2022-08-08 12:05:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-08 12:05:07 +0000 |
| commit | 49700e46366bfe7958204877b4edcf74987ec508 (patch) | |
| tree | b0b8e61eb9d0b6f5531e384ff98382fda8f659fd | |
| parent | 20d64412c0c3974708c8cb00d8c50c8a82d27191 (diff) | |
| parent | 4b648d8f6cfb9f58490a70e4539aa36c89b9d35e (diff) | |
| download | rust-49700e46366bfe7958204877b4edcf74987ec508.tar.gz rust-49700e46366bfe7958204877b4edcf74987ec508.zip | |
Auto merge of #12967 - jhgg:code/fix-toggle-hints, r=Veykril
[code] make toggleInlayHints understand {off,on}UntilPressed
fixes #12964
| -rw-r--r-- | editors/code/src/commands.ts | 18 |
1 files changed, 16 insertions, 2 deletions
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); }; } |
