diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-16 23:41:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-16 23:41:12 +0300 |
| commit | c971c7f8a88d11f2b692a1bcd4d17b9b0c1a11d2 (patch) | |
| tree | 9edb25a2f044d4c63a61dbc870b10d5b1cf8415f /internal/lsp/handlers_test.go | |
| parent | 4974b40bd5126cb4215580c0d066057a973f50d1 (diff) | |
fix(lsp): avoid duplicate assignment prefix in completions
- Prompt: instruct model to only continue from cursor; do not repeat LHS already typed.\n- Add stripDuplicateAssignmentPrefix to drop duplicated 'name :=' or 'name =' when model repeats it.\n- Tests: cover := and = cases.\n- .gitignore: ignore built binary and go caches.
Diffstat (limited to 'internal/lsp/handlers_test.go')
| -rw-r--r-- | internal/lsp/handlers_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/lsp/handlers_test.go b/internal/lsp/handlers_test.go index 0b12611..1b5080a 100644 --- a/internal/lsp/handlers_test.go +++ b/internal/lsp/handlers_test.go @@ -238,3 +238,19 @@ func TestInstructionFromSelection_HTMLAndLineComments(t *testing.T) { t.Fatalf("cleaned should remove html comment markers") } } + +func TestStripDuplicateAssignmentPrefix(t *testing.T) { + prefix := "matrix := " + sug := "matrix := NewMatrix(2,2)" + got := stripDuplicateAssignmentPrefix(prefix, sug) + if got != "NewMatrix(2,2)" { + t.Fatalf("dup strip failed: got %q", got) + } + // '=' variant + prefix2 := "x = " + sug2 := "x = y + 1" + got2 := stripDuplicateAssignmentPrefix(prefix2, sug2) + if got2 != "y + 1" { + t.Fatalf("dup strip '=' failed: got %q", got2) + } +} |
