diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 10:56:27 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 10:56:27 +0300 |
| commit | 320de746f7a2985b60c8564a0e65bdf231e840b7 (patch) | |
| tree | e70bcf50813dba411afa2934e774383124bbc99e /internal/lsp/helpers_inline_prompt_test.go | |
| parent | 06247527d5170f329b454b42f59a3e4434ab1f4b (diff) | |
use gofumpt
Diffstat (limited to 'internal/lsp/helpers_inline_prompt_test.go')
| -rw-r--r-- | internal/lsp/helpers_inline_prompt_test.go | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/internal/lsp/helpers_inline_prompt_test.go b/internal/lsp/helpers_inline_prompt_test.go index 81312b4..4aaf892 100644 --- a/internal/lsp/helpers_inline_prompt_test.go +++ b/internal/lsp/helpers_inline_prompt_test.go @@ -1,58 +1,62 @@ package lsp import ( - "encoding/json" - "testing" + "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>") - } + // 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") - } + 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") - } + 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") - } + 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") - } + 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") + } } |
