Skip to content

Commit b7a1df7

Browse files
committed
Fix inlay hints toggle after vscode updates (enablement is 4-state)
1 parent a562edc commit b7a1df7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/inlay-hints.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,21 @@ class InlayHintsFeature implements vscodelc.StaticFeature {
6767
const enabledSetting = 'editor.inlayHints.enabled';
6868
this.context.subscriptions.push(
6969
vscode.commands.registerCommand('clangd.inlayHints.toggle', () => {
70-
const current = vscode.workspace.getConfiguration().get<boolean>(
71-
enabledSetting, false);
70+
// This used to be a boolean, and then became a 4-state enum.
71+
var val = vscode.workspace.getConfiguration().get<boolean | string>(
72+
enabledSetting, "on");
73+
if (val === true || val === "on")
74+
val = "off"
75+
else if (val === false || val === "off")
76+
val = "on";
77+
else if (val === "offUnlessPressed")
78+
val = "onUnlessPressed";
79+
else if (val == "onUnlessPressed")
80+
val = "offUnlessPressed";
81+
else
82+
return;
7283
vscode.workspace.getConfiguration().update(
73-
enabledSetting, !current, vscode.ConfigurationTarget.Global);
84+
enabledSetting, val, vscode.ConfigurationTarget.Global);
7485
}));
7586
}
7687
// If the clangd server supports LSP 3.17 inlay hints, these are handled by

0 commit comments

Comments
 (0)