Skip to content

Commit 363c1f2

Browse files
bors[bot]matklad
andauthored
Merge #4372
4372: Add master config for inlayHints to make disabling easy r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 6f2f904 + 3bf5ef0 commit 363c1f2

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@
300300
"default": true,
301301
"markdownDescription": "Check with all features (will be passed as `--all-features`)"
302302
},
303+
"rust-analyzer.inlayHints.enable": {
304+
"type": "boolean",
305+
"default": true,
306+
"description": "Disable all inlay hints"
307+
},
303308
"rust-analyzer.inlayHints.typeHints": {
304309
"type": "boolean",
305310
"default": true,

editors/code/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export class Config {
9494

9595
get inlayHints() {
9696
return {
97+
enable: this.get<boolean>("inlayHints.enable"),
9798
typeHints: this.get<boolean>("inlayHints.typeHints"),
9899
parameterHints: this.get<boolean>("inlayHints.parameterHints"),
99100
chainingHints: this.get<boolean>("inlayHints.chainingHints"),

editors/code/src/inlay_hints.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export function activateInlayHints(ctx: Ctx) {
1010
const maybeUpdater = {
1111
updater: null as null | HintsUpdater,
1212
async onConfigChange() {
13-
if (
14-
!ctx.config.inlayHints.typeHints &&
15-
!ctx.config.inlayHints.parameterHints &&
16-
!ctx.config.inlayHints.chainingHints
17-
) {
18-
return this.dispose();
19-
}
13+
const anyEnabled = ctx.config.inlayHints.typeHints
14+
|| ctx.config.inlayHints.parameterHints
15+
|| ctx.config.inlayHints.chainingHints;
16+
const enabled = ctx.config.inlayHints.enable && anyEnabled;
17+
18+
if (!enabled) return this.dispose();
19+
2020
await sleep(100);
2121
if (this.updater) {
2222
this.updater.syncCacheAndRenderHints();

0 commit comments

Comments
 (0)