diff options
Diffstat (limited to 'internal/lsp/document_test.go')
| -rw-r--r-- | internal/lsp/document_test.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/internal/lsp/document_test.go b/internal/lsp/document_test.go index 4bd96e2..5fee18b 100644 --- a/internal/lsp/document_test.go +++ b/internal/lsp/document_test.go @@ -9,10 +9,20 @@ import ( ) func newTestServer() *Server { - return &Server{ - logger: log.New(io.Discard, "", 0), - docs: make(map[string]*document), - } + s := &Server{ + logger: log.New(io.Discard, "", 0), + docs: make(map[string]*document), + inlineOpen: ">", + inlineClose: ">", + chatSuffix: ">", + chatPrefixes: []string{"?","!",":",";"}, + } + // Keep package-level helpers in sync for tests using free functions + inlineOpenChar = '>' + inlineCloseChar = '>' + chatSuffixChar = '>' + chatPrefixSingles = []string{"?","!",":",";"} + return s } func TestSplitLines(t *testing.T) { @@ -60,6 +70,15 @@ func TestLineContext_EmptyDoc(t *testing.T) { } } +func TestDocBeforeAfter_ClampsIndices(t *testing.T) { + s := newTestServer() + uri := "file:///clamp.go" + s.setDocument(uri, "abc\nxyz") + // Position beyond document length should be clamped safely + before, after := s.docBeforeAfter(uri, Position{Line: 99, Character: 99}) + if before == "" && after == "" { t.Fatalf("expected some text with clamped indices") } +} + func TestTrimLen(t *testing.T) { long := strings.Repeat("a", 205) got := trimLen(long) |
