summaryrefslogtreecommitdiff
path: root/internal/lsp/chat_trigger_suppression_test.go
blob: 852f955b0ccbf9de12282aa5b760d3585eb48874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package lsp

import "testing"

// Ensure completion is suppressed when a chat trigger is at EOL (?>,!>,:>,;>)
func TestCompletionSuppressedOnChatTriggerEOL(t *testing.T) {
	s := newTestServer()
	s.cfg.MaxTokens = 32
	s.cfg.TriggerCharacters = []string{".", ":", "/", "_"}
	s.compCache = make(map[string]string)
	initServerDefaults(s)
	s.llmClient = &countingLLM{}
	tests := []string{"What now?>", "Explain!>", "Refactor:>", "note ;>"}
	for i, line := range tests {
		p := CompletionParams{Position: Position{Line: 0, Character: len(line)}, TextDocument: TextDocumentIdentifier{URI: "file://chat-suppr.go"}}
		items, ok, _ := s.tryLLMCompletion(p, "", line, "", "", "", false, "")
		if !ok {
			t.Fatalf("case %d: expected ok=true", i)
		}
		if len(items) != 0 {
			t.Fatalf("case %d: expected no completion items for EOL chat trigger", i)
		}
	}
}