Skip to content

Commit

Permalink
Auto merge of rust-lang#12967 - jhgg:code/fix-toggle-hints, r=Veykril
Browse files Browse the repository at this point in the history
[code] make toggleInlayHints understand {off,on}UntilPressed

fixes rust-lang#12964
  • Loading branch information
bors committed Aug 8, 2022
2 parents 20d6441 + 4b648d8 commit 49700e4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions editors/code/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}

Expand Down

0 comments on commit 49700e4

Please sign in to comment.