diff options
| author | Damian Tarnawski <gthetarnav@gmail.com> | 2025-07-04 21:08:19 +0200 |
|---|---|---|
| committer | Damian Tarnawski <gthetarnav@gmail.com> | 2025-07-04 21:08:19 +0200 |
| commit | 384aaa75affae6fdceca2811ddd9a0b57d842e2d (patch) | |
| tree | 9f2ef39f10eadd534ebd3e991f2eada317ef49f2 /src | |
| parent | 90e3c54b0ed5880e35271ae5095e04abd0d636c9 (diff) | |
Support inlay hints with named params
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/inlay_hints.odin | 13 | ||||
| -rw-r--r-- | src/testing/testing.odin | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/server/inlay_hints.odin b/src/server/inlay_hints.odin index 07fdfd1..e4cea54 100644 --- a/src/server/inlay_hints.odin +++ b/src/server/inlay_hints.odin @@ -64,13 +64,6 @@ get_inlay_hints :: proc( call := node_call.derived.(^ast.Call_Expr) - // TODO: support this (inlay hints in calls that use named args, e.g. `foobar(foo=bar)` - for arg in call.args { - if _, ok := arg.derived.(^ast.Field_Value); ok { - continue loop - } - } - if selector, ok := call.expr.derived.(^ast.Selector_Expr); ok && selector.op.kind == .Arrow_Right { is_selector_call = true } @@ -147,6 +140,12 @@ get_inlay_hints :: proc( has_added_default = true } else if config.enable_inlay_hints_params { + // if is already provided as a named argument + if _, ok := call.args[symbol_arg_count].derived.(^ast.Field_Value); ok { + symbol_arg_count += 1 + continue + } + // if the arg name and param name are the same, don't add it. same_name: bool #partial switch v in call.args[symbol_arg_count].derived_expr { diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 48e562b..78df00e 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -445,7 +445,7 @@ expect_inlay_hints :: proc(t: ^testing.T, src: ^Source, expected_hints: []server for i in 0 ..< min(len(expected_hints), len(hints)) { e, a := expected_hints[i], hints[i] if e != a { - log.errorf("[%d]: Expected inlay hint %v, but received %v", i, e, a) + log.errorf("[%d]: Expected inlay hint\n%v, but received\n%v", i, e, a) } } } |