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/helpers_inline_prompt_test.go | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 internal/lsp/helpers_inline_prompt_test.go (limited to 'internal/lsp/helpers_inline_prompt_test.go') diff --git a/internal/lsp/helpers_inline_prompt_test.go b/internal/lsp/helpers_inline_prompt_test.go new file mode 100644 index 0000000..81312b4 --- /dev/null +++ b/internal/lsp/helpers_inline_prompt_test.go @@ -0,0 +1,58 @@ +package lsp + +import ( + "encoding/json" + "testing" +) + +func TestLineHasInlinePrompt_BasicAndDoubleOpen(t *testing.T) { + // Basic inline + if !lineHasInlinePrompt("do >task> now") { + t.Fatalf("expected inline prompt detection for >text>") + } + // Double-open variant should be recognized as inline prompt too + if !lineHasInlinePrompt(">>replace>") { + t.Fatalf("expected inline prompt detection for >>text>") + } +} + +func TestIsTriggerEvent_TriggerCharNotAllowed(t *testing.T) { + s := newTestServer() + s.triggerChars = []string{"."} // only dot allowed + p := CompletionParams{Position: Position{Line:0, Character:3}} + if s.isTriggerEvent(p, "ab:") { // ':' not in triggerChars + t.Fatalf("expected false when TriggerCharacter not configured") + } +} + +func TestShouldSuppressForChatTriggerEOL_EmptySuffix_NoSuppression(t *testing.T) { + s := newTestServer() + s.chatSuffix = "" // disabled + p := CompletionParams{Position: Position{Line:0, Character:5}} + if s.shouldSuppressForChatTriggerEOL("What?>", p) { + t.Fatalf("expected no suppression when chat suffix is empty") + } +} + +func TestIsTriggerEvent_TriggerCharacterMissing_ReturnsFalse(t *testing.T) { + s := newTestServer() + // Context says TriggerCharacter, but none provided + ctx := struct{ TriggerKind int `json:"triggerKind"` }{TriggerKind: 2} + raw, _ := json.Marshal(ctx) + p := CompletionParams{Position: Position{Line:0, Character:1}, Context: json.RawMessage(raw)} + if s.isTriggerEvent(p, "a") { + t.Fatalf("expected false when TriggerCharacter kind with empty char") + } +} + +func TestIsTriggerEvent_TriggerForIncomplete_FallsBackToChar(t *testing.T) { + s := newTestServer() + s.triggerChars = []string{"."} + // TriggerKind=3 should consult fallback char check + ctx := struct{ TriggerKind int `json:"triggerKind"` }{TriggerKind: 3} + raw, _ := json.Marshal(ctx) + p := CompletionParams{Position: Position{Line:0, Character:2}, Context: json.RawMessage(raw)} + if !s.isTriggerEvent(p, "x.") { + t.Fatalf("expected true via fallback char for TriggerForIncomplete") + } +} -- cgit v1.2.3