diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-19 21:32:09 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-19 21:32:09 +0300 |
| commit | 526e40a54ba325a6f75f35817799614d7b5997b7 (patch) | |
| tree | ba25459399835d99b5785872cf9da8c2d64ed136 /internal/lsp/handlers_helpers_test.go | |
| parent | 041196eab701b7a7ac79baf486a7c11fc11913e3 (diff) | |
lsp: strip inline spans for completions\n\n- Add stripInlineCodeSpan helper to extract first inline backtick span\n- Apply only in completion path after fence stripping\n- Add comprehensive unit tests for inline span handling
Diffstat (limited to 'internal/lsp/handlers_helpers_test.go')
| -rw-r--r-- | internal/lsp/handlers_helpers_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/lsp/handlers_helpers_test.go b/internal/lsp/handlers_helpers_test.go index f9ed18a..11fe29f 100644 --- a/internal/lsp/handlers_helpers_test.go +++ b/internal/lsp/handlers_helpers_test.go @@ -69,3 +69,24 @@ func TestStripCodeFences(t *testing.T) { } } } + +func TestStripInlineCodeSpan(t *testing.T) { + cases := []struct{ + name string + in string + want string + }{ + {"no backticks", "return x + y", "return x + y"}, + {"single inline", "Use `foo(bar)` here", "foo(bar)"}, + {"just inline", "`x := y()`", "x := y()"}, + {"unmatched start", "use `foo(bar) without end", "use `foo(bar) without end"}, + {"multiple spans picks first", "`a` and also `b`", "a"}, + {"leading/trailing spaces", " text ` z ` ", " z "}, + } + for _, tc := range cases { + got := stripInlineCodeSpan(tc.in) + if got != tc.want { + t.Fatalf("%s: got %q want %q", tc.name, got, tc.want) + } + } +} |
