dotnet / dotnet/vscode-csharp

Improve inlay hint suppression options

Open
#8,862 0 comments 3 reactions 2 assignees Assigned to @akhera99 View on GitHub
Editor-IntelliSense
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
17h 56m
Merged PRs (30d)
21

Description

## Is your feature request related to a problem? Please describe.
I find inlay hints extremely useful, but when enabled, they show up everywhere, and the options to suppress them when they're not necessary are very lacking

## Describe the solution you would like
`dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName` should (or have an option to) ignore case and punctuation:
```csharp
void fn(int fooBar) { }

// Hidden:
fn(fooBar);

// Not hidden:
fn(/*fooBar: */_fooBar);
fn(/*fooBar: */FooBar);
fn(/*fooBar: */FOO_BAR);
```

`dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix` doesn't seem to work at all:
```csharp
fn(/*fooBar: */fooBar_);

void fn2(int fooBar_) { }

fn2(/*fooBar_: */fooBar);
```

There should be an option to hide inlay hints for parameters ending with a member access that matches argument name:
```csharp
Vector2 bar = new(/*x: */foo.X, /*y: */foo.Y);
```

There should be an option to hide inlay hints for collection indexer parameters:
```csharp
someArr[/*index: */i];
```

And there should be an option to hide locally apparent type hints for target-typed new and collection expressions:
```csharp
// Caused by `csharp.inlayHints.enableInlayHintsForImplicitObjectCreation`:
Vector2 foo = new/*Vector2*/(1, 2);

// Caused by `csharp.inlayHints.enableInlayHintsForTypes`:
int[] bar = /*int[]*/[1, 2, 3];
```

These options would reduce the clutter of unneeded hints while keeping hints for more ambiguous cases

## Applicable Scenarios
When someone is using inlay hints for parameters, implicit object creation, and types

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.