diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index e097100c2f..2f46ff304b 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -949,9 +949,16 @@ func (r *runner) InlayHints(t *testing.T, spn span.Span) { // Map inlay hints to text edits. edits := make([]protocol.TextEdit, len(hints)) for i, hint := range hints { + var paddingLeft, paddingRight string + if hint.PaddingLeft { + paddingLeft = " " + } + if hint.PaddingRight { + paddingRight = " " + } edits[i] = protocol.TextEdit{ Range: protocol.Range{Start: *hint.Position, End: *hint.Position}, - NewText: fmt.Sprintf("<%s>", hint.Label[0].Value), + NewText: fmt.Sprintf("<%s%s%s>", paddingLeft, hint.Label[0].Value, paddingRight), } } diff --git a/internal/lsp/testdata/inlay_hint/composite_literals.go.golden b/internal/lsp/testdata/inlay_hint/composite_literals.go.golden index efa87b0fea..ecff780038 100644 --- a/internal/lsp/testdata/inlay_hint/composite_literals.go.golden +++ b/internal/lsp/testdata/inlay_hint/composite_literals.go.golden @@ -4,14 +4,14 @@ package inlayHint //@inlayHint("package") import "fmt" func fieldNames() { - for _, c := range []struct { + for _< int>, c< struct{in string; want strin...> := range []struct { in, want string }{ - {"Hello, world", "dlrow ,olleH"}, - {"Hello, 世界", "界世 ,olleH"}, - {"", ""}, + {"Hello, world", "dlrow ,olleH"}, + {"Hello, 世界", "界世 ,olleH"}, + {"", ""}, } { - fmt.Println(c.in == c.want) + fmt.Println(c.in == c.want) } } diff --git a/internal/lsp/testdata/inlay_hint/constant_values.go.golden b/internal/lsp/testdata/inlay_hint/constant_values.go.golden index 69481b10d6..edc46debc3 100644 --- a/internal/lsp/testdata/inlay_hint/constant_values.go.golden +++ b/internal/lsp/testdata/inlay_hint/constant_values.go.golden @@ -6,24 +6,24 @@ const True = true type Kind int const ( - KindNone Kind = iota<= 0> - KindPrint<= 1> - KindPrintf<= 2> - KindErrorf<= 3> + KindNone Kind = iota< = 0> + KindPrint< = 1> + KindPrintf< = 2> + KindErrorf< = 3> ) const ( - u = iota * 4<= 0> - v float64 = iota * 42<= 42> - w = iota * 42<= 84> + u = iota * 4< = 0> + v float64 = iota * 42< = 42> + w = iota * 42< = 84> ) const ( a, b = 1, 2 - c, d<= 1, 2> - e, f = 5 * 5, "hello" + "world"<= 25, "helloworld"> - g, h<= 25, "helloworld"> - i, j = true, f<= true, "helloworld"> + c, d< = 1, 2> + e, f = 5 * 5, "hello" + "world"< = 25, "helloworld"> + g, h< = 25, "helloworld"> + i, j = true, f< = true, "helloworld"> ) // No hint diff --git a/internal/lsp/testdata/inlay_hint/parameter_names.go.golden b/internal/lsp/testdata/inlay_hint/parameter_names.go.golden index 66351e4830..46d3ea4e9b 100644 --- a/internal/lsp/testdata/inlay_hint/parameter_names.go.golden +++ b/internal/lsp/testdata/inlay_hint/parameter_names.go.golden @@ -8,7 +8,7 @@ func hello(name string) string { } func helloWorld() string { - return hello("World") + return hello("World") } type foo struct{} @@ -21,27 +21,27 @@ func (*foo) bar(baz string, qux int) int { } func kase(foo int, bar bool, baz ...string) { - fmt.Println(foo, bar, baz) + fmt.Println(foo, bar, baz) } func kipp(foo string, bar, baz string) { - fmt.Println(foo, bar, baz) + fmt.Println(foo, bar, baz) } func plex(foo, bar string, baz string) { - fmt.Println(foo, bar, baz) + fmt.Println(foo, bar, baz) } func tars(foo string, bar, baz string) { - fmt.Println(foo, bar, baz) + fmt.Println(foo, bar, baz) } func foobar() { var x foo - x.bar("", 1) - kase(0, true, "c", "d", "e") - kipp("a", "b", "c") - plex("a", "b", "c") - tars("a", "b", "c") + x.bar("", 1) + kase(0, true, "c", "d", "e") + kipp("a", "b", "c") + plex("a", "b", "c") + tars("a", "b", "c") } diff --git a/internal/lsp/testdata/inlay_hint/variable_types.go.golden b/internal/lsp/testdata/inlay_hint/variable_types.go.golden index 70c019caa1..6039950d5f 100644 --- a/internal/lsp/testdata/inlay_hint/variable_types.go.golden +++ b/internal/lsp/testdata/inlay_hint/variable_types.go.golden @@ -2,21 +2,21 @@ package inlayHint //@inlayHint("package") func assignTypes() { - i, j := 0, len([]string{})-1 + i< int>, j< int> := 0, len([]string{})-1 println(i, j) } func rangeTypes() { - for k, v := range []string{} { + for k< int>, v< string> := range []string{} { println(k, v) } } func funcLitType() { - myFunc := func(a string) string { return "" } + myFunc< func(a string) string> := func(a string) string { return "" } } func compositeLitType() { - foo := map[string]interface{}{"": ""} + foo< map[string]interface{}> := map[string]interface{}{"": ""} }