diff options
Diffstat (limited to 'internal/lsp/completion_prefix_strip_test.go')
| -rw-r--r-- | internal/lsp/completion_prefix_strip_test.go | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/internal/lsp/completion_prefix_strip_test.go b/internal/lsp/completion_prefix_strip_test.go index acc7921..6173d6f 100644 --- a/internal/lsp/completion_prefix_strip_test.go +++ b/internal/lsp/completion_prefix_strip_test.go @@ -41,8 +41,12 @@ func TestStripDuplicateAssignmentPrefix_AssignAndWalrus(t *testing.T) { } func TestTryLLMCompletion_ManualInvokeAfterWhitespace_Allows(t *testing.T) { - s := &Server{maxTokens: 32, triggerChars: []string{".", ":", "/", "_"}, compCache: make(map[string]string)} - initServerDefaults(s) + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg s.llmClient = fakeLLM{resp: tut.MultilineFunctionSuggestion()} line := "func fib(i int) " // cursor after space p := CompletionParams{Position: Position{Line: 0, Character: len(line)}, TextDocument: TextDocumentIdentifier{URI: "file://x.go"}} @@ -58,8 +62,12 @@ func TestTryLLMCompletion_ManualInvokeAfterWhitespace_Allows(t *testing.T) { } func TestTryLLMCompletion_InlinePromptAlwaysTriggers(t *testing.T) { - s := &Server{maxTokens: 32, triggerChars: []string{".", ":", "/", "_"}, compCache: make(map[string]string)} - initServerDefaults(s) + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg s.llmClient = fakeLLM{resp: "replacement"} line := "prefix >do something> suffix" // No trigger char immediately before cursor; place cursor at end @@ -71,17 +79,12 @@ func TestTryLLMCompletion_InlinePromptAlwaysTriggers(t *testing.T) { } func TestTryLLMCompletion_DoubleOpenEmpty_DoesNotAutoTrigger(t *testing.T) { - s := &Server{ - maxTokens: 32, - triggerChars: []string{".", ":", "/", "_"}, - compCache: make(map[string]string), - inlineOpen: ">", - inlineClose: ">", - inlineOpenChar: '>', - inlineCloseChar: '>', - } - initServerDefaults(s) - initServerDefaults(s) + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg fake := &countingLLM{} s.llmClient = fake line := ">> " // empty content after double-open should not force-trigger @@ -114,15 +117,12 @@ func TestHasDoubleSemicolonTrigger_Variants(t *testing.T) { } func TestBareDoubleOpenPreventsAutoTriggerEvenWithOtherTriggers(t *testing.T) { - s := &Server{ - maxTokens: 32, - triggerChars: []string{".", ":", "/", "_"}, - compCache: make(map[string]string), - inlineOpen: ">", - inlineClose: ">", - inlineOpenChar: '>', - inlineCloseChar: '>', - } + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg fake := &countingLLM{} s.llmClient = fake // Place a '.' earlier but also include bare double-open at end; should not auto-trigger @@ -141,8 +141,12 @@ func TestBareDoubleOpenPreventsAutoTriggerEvenWithOtherTriggers(t *testing.T) { } func TestBareDoubleOpenOnNextLine_PreventsAutoTrigger(t *testing.T) { - s := &Server{maxTokens: 32, triggerChars: []string{".", ":", "/", "_"}, compCache: make(map[string]string)} - initServerDefaults(s) + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg fake := &countingLLM{} s.llmClient = fake current := "expression := flag.String(\"expression\", \"\", \"Expression to evaluate\")" @@ -161,8 +165,12 @@ func TestBareDoubleOpenOnNextLine_PreventsAutoTrigger(t *testing.T) { } func TestBareDoubleOpenPreventsManualInvoke(t *testing.T) { - s := &Server{maxTokens: 32, triggerChars: []string{".", ":", "/", "_"}, compCache: make(map[string]string)} - initServerDefaults(s) + s := newTestServer() + s.compCache = make(map[string]string) + cfg := s.cfg + cfg.MaxTokens = 32 + cfg.TriggerCharacters = []string{".", ":", "/", "_"} + s.cfg = cfg fake := &countingLLM{} s.llmClient = fake line := ">>" |
