From 526e40a54ba325a6f75f35817799614d7b5997b7 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 19 Aug 2025 21:32:09 +0300 Subject: 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 --- internal/lsp/handlers_helpers_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/lsp/handlers_helpers_test.go') 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) + } + } +} -- cgit v1.2.3