From 5be9532cfa630f4aacd8d879c3e4f5cc316da0fa Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Sep 2025 10:25:36 +0300 Subject: feat(lsp): configurable inline/chat triggers; switch inline markers to >text>/>>text>; update docs and example config; tests updated to new triggers and raise LSP coverage to >=85%; chore: remove semicolon legacy; chore(mage): auto-refresh coverage daily if docs/coverage.out is older than 24h --- internal/lsp/transport_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'internal/lsp/transport_test.go') diff --git a/internal/lsp/transport_test.go b/internal/lsp/transport_test.go index 0a01acd..c00b405 100644 --- a/internal/lsp/transport_test.go +++ b/internal/lsp/transport_test.go @@ -17,6 +17,20 @@ func TestReadMessage_ParsesContentLength(t *testing.T) { if err != nil || string(got) != string(body) { t.Fatalf("readMessage failed: %v %q", err, string(got)) } } +func TestWriteMessage_FramesJSON(t *testing.T) { + var out bytes.Buffer + s := &Server{out: &out} + payload := struct{ JSONRPC string `json:"jsonrpc"`; Ping string `json:"ping"` }{JSONRPC: "2.0", Ping: "pong"} + s.writeMessage(payload) + got := out.String() + if !bytes.HasPrefix([]byte(got), []byte("Content-Length: ")) { t.Fatalf("missing Content-Length header: %q", got) } + // Header/body delimiter must be present + idx := bytes.Index([]byte(got), []byte("\r\n\r\n")) + if idx < 0 { t.Fatalf("missing CRLFCRLF delimiter: %q", got) } + body := got[idx+4:] + if body == "" || body[0] != '{' || body[len(body)-1] != '}' { t.Fatalf("body not JSON: %q", body) } +} + func stringInt(n int) string { if n == 0 { return "0" } var b [20]byte @@ -24,4 +38,3 @@ func stringInt(n int) string { for n > 0 { i--; b[i] = byte('0' + n%10); n /= 10 } return string(b[i:]) } - -- cgit v1.2.3