diff options
| author | Jake Heinz <jh@discordapp.com> | 2022-08-08 00:20:17 +0000 |
|---|---|---|
| committer | Jake Heinz <jh@discordapp.com> | 2022-08-08 02:32:49 +0000 |
| commit | 4b648d8f6cfb9f58490a70e4539aa36c89b9d35e (patch) | |
| tree | 389a68182ea37abf390166b2dd0cc45c8984f493 | |
| parent | 634cfe3d72e785c843ca5d412b12be137b2e14fb (diff) | |
| download | rust-4b648d8f6cfb9f58490a70e4539aa36c89b9d35e.tar.gz rust-4b648d8f6cfb9f58490a70e4539aa36c89b9d35e.zip | |
[code] make toggleInlayHints understand {off,on}UntilPressed
| -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); }; } |
