diff options
Diffstat (limited to 'internal/lsp')
| -rw-r--r-- | internal/lsp/compute_textedit_table_test.go | 6 | ||||
| -rw-r--r-- | internal/lsp/handlers_utils.go | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/internal/lsp/compute_textedit_table_test.go b/internal/lsp/compute_textedit_table_test.go index 6ed5330..b53f9a1 100644 --- a/internal/lsp/compute_textedit_table_test.go +++ b/internal/lsp/compute_textedit_table_test.go @@ -15,16 +15,14 @@ func TestComputeTextEditAndFilter_Table(t *testing.T) { {"params_at_close", true, "func add(a int)", Position{Line: 0, Character: len("func add(a int)")}, "b string"}, } for _, c := range cases { - te, filter := computeTextEditAndFilter(c.cleaned, c.inParams, c.current, CompletionParams{Position: c.pos}) + te, _ := computeTextEditAndFilter(c.cleaned, c.inParams, c.current, CompletionParams{Position: c.pos}) if te == nil { t.Fatalf("%s: expected edit", c.name) } if c.inParams && te.Range.Start.Character == 0 { t.Fatalf("%s: expected param range (non-zero start)", c.name) } - if filter == "" && c.current != "" { - // For ident_replace, filter may be non-empty; for params, it can be empty when replacing entire segment - } + if te.NewText != c.cleaned { t.Fatalf("%s: newText got %q want %q", c.name, te.NewText, c.cleaned) } diff --git a/internal/lsp/handlers_utils.go b/internal/lsp/handlers_utils.go index b3056b9..10cc739 100644 --- a/internal/lsp/handlers_utils.go +++ b/internal/lsp/handlers_utils.go @@ -31,7 +31,6 @@ type requestSpec struct { index int } -func (r requestSpec) modelOverride() string { return strings.TrimSpace(r.entry.Model) } func (r requestSpec) effectiveModel(defaultModel string) string { if m := strings.TrimSpace(r.entry.Model); m != "" { @@ -490,7 +489,7 @@ func stripDuplicateAssignmentPrefix(prefixBeforeCursor, suggestion string) strin } // Fallback to plain '=' if present if idx := strings.LastIndex(prefixBeforeCursor, "="); idx >= 0 { - if !(idx > 0 && prefixBeforeCursor[idx-1] == ':') { // not := + if idx <= 0 || prefixBeforeCursor[idx-1] != ':' { // not := tail := prefixBeforeCursor[idx+1:] if strings.TrimSpace(tail) == "" { start := idx - 1 @@ -534,7 +533,7 @@ func stripDuplicateGeneralPrefix(prefixBeforeCursor, suggestion string) string { } func isIdentBoundary(ch byte) bool { - return !((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '_') + return !isIdentChar(ch) } // stripCodeFences removes surrounding Markdown code fences from a model response. |
