summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--internal/llm/tools/edit.go4
-rw-r--r--internal/lsp/util/edit.go8
-rw-r--r--internal/lsp/watcher/watcher.go2
-rw-r--r--internal/tui/components/core/button.go6
-rw-r--r--internal/tui/components/repl/messages.go6
-rw-r--r--internal/tui/layout/grid.go4
-rw-r--r--internal/tui/layout/overlay.go7
7 files changed, 13 insertions, 24 deletions
diff --git a/internal/llm/tools/edit.go b/internal/llm/tools/edit.go
index c84bbd7a0..a5877044b 100644
--- a/internal/llm/tools/edit.go
+++ b/internal/llm/tools/edit.go
@@ -80,7 +80,7 @@ func (e *editTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
if err != nil {
return NewTextErrorResponse(fmt.Sprintf("error creating file: %s", err)), nil
}
- return NewTextErrorResponse(result), nil
+ return NewTextResponse(result), nil
}
if params.NewString == "" {
@@ -88,7 +88,7 @@ func (e *editTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
if err != nil {
return NewTextErrorResponse(fmt.Sprintf("error deleting content: %s", err)), nil
}
- return NewTextErrorResponse(result), nil
+ return NewTextResponse(result), nil
}
result, err := replaceContent(params.FilePath, params.OldString, params.NewString)
diff --git a/internal/lsp/util/edit.go b/internal/lsp/util/edit.go
index 180429ce5..3b94fb39f 100644
--- a/internal/lsp/util/edit.go
+++ b/internal/lsp/util/edit.go
@@ -34,9 +34,9 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
lines := strings.Split(string(content), lineEnding)
// Check for overlapping edits
- for i := 0; i < len(edits); i++ {
+ for i, edit1 := range edits {
for j := i + 1; j < len(edits); j++ {
- if rangesOverlap(edits[i].Range, edits[j].Range) {
+ if rangesOverlap(edit1.Range, edits[j].Range) {
return fmt.Errorf("overlapping edits detected between edit %d and %d", i, j)
}
}
@@ -54,7 +54,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
// Apply each edit
for _, edit := range sortedEdits {
- newLines, err := applyTextEdit(lines, edit, lineEnding)
+ newLines, err := applyTextEdit(lines, edit)
if err != nil {
return fmt.Errorf("failed to apply edit: %w", err)
}
@@ -82,7 +82,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
return nil
}
-func applyTextEdit(lines []string, edit protocol.TextEdit, lineEnding string) ([]string, error) {
+func applyTextEdit(lines []string, edit protocol.TextEdit) ([]string, error) {
startLine := int(edit.Range.Start.Line)
endLine := int(edit.Range.End.Line)
startChar := int(edit.Range.Start.Character)
diff --git a/internal/lsp/watcher/watcher.go b/internal/lsp/watcher/watcher.go
index a9d057c71..7a6eaacc5 100644
--- a/internal/lsp/watcher/watcher.go
+++ b/internal/lsp/watcher/watcher.go
@@ -347,7 +347,7 @@ func matchesSimpleGlob(pattern, path string) bool {
// Otherwise, check if any path component matches
pathComponents := strings.Split(path, "/")
- for i := 0; i < len(pathComponents); i++ {
+ for i := range pathComponents {
subPath := strings.Join(pathComponents[i:], "/")
if strings.HasSuffix(subPath, rest) {
return true
diff --git a/internal/tui/components/core/button.go b/internal/tui/components/core/button.go
index 102957e0e..090fbc1ee 100644
--- a/internal/tui/components/core/button.go
+++ b/internal/tui/components/core/button.go
@@ -67,7 +67,7 @@ const (
// ButtonMsg is sent when a button is clicked
type ButtonMsg struct {
ID string
- Payload interface{}
+ Payload any
}
// ButtonCmp represents a clickable button component
@@ -79,7 +79,7 @@ type ButtonCmp struct {
state ButtonState
variant ButtonVariant
keyMap ButtonKeyMap
- payload interface{}
+ payload any
style lipgloss.Style
hoverStyle lipgloss.Style
}
@@ -107,7 +107,7 @@ func (b *ButtonCmp) WithVariant(variant ButtonVariant) *ButtonCmp {
}
// WithPayload sets the payload sent with button events
-func (b *ButtonCmp) WithPayload(payload interface{}) *ButtonCmp {
+func (b *ButtonCmp) WithPayload(payload any) *ButtonCmp {
b.payload = payload
return b
}
diff --git a/internal/tui/components/repl/messages.go b/internal/tui/components/repl/messages.go
index 2b5e599aa..30ce4be7c 100644
--- a/internal/tui/components/repl/messages.go
+++ b/internal/tui/components/repl/messages.go
@@ -5,7 +5,6 @@ import (
"fmt"
"sort"
"strings"
- "time"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/viewport"
@@ -41,7 +40,6 @@ type messagesCmp struct {
height int
focused bool
cachedView string
- timeLoaded time.Time
}
func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@@ -424,9 +422,6 @@ func (m *messagesCmp) projectDiagnostics() string {
}
if len(errorDiagnostics) == 0 && len(warnDiagnostics) == 0 && len(hintDiagnostics) == 0 && len(infoDiagnostics) == 0 {
- if time.Since(m.timeLoaded) < time.Second*10 {
- return "Loading diagnostics..."
- }
return "No diagnostics"
}
@@ -496,7 +491,6 @@ func (m *messagesCmp) SetSize(width int, height int) {
}
func (m *messagesCmp) Init() tea.Cmd {
- m.timeLoaded = time.Now()
return nil
}
diff --git a/internal/tui/layout/grid.go b/internal/tui/layout/grid.go
index d6f0b4ab9..6be493e2c 100644
--- a/internal/tui/layout/grid.go
+++ b/internal/tui/layout/grid.go
@@ -127,10 +127,10 @@ func (g *gridLayout) View() string {
// Render each row
rows := make([]string, g.rows)
- for i := 0; i < g.rows; i++ {
+ for i := range g.rows {
// Render each column in this row
cols := make([]string, len(g.panes[i]))
- for j := 0; j < len(g.panes[i]); j++ {
+ for j := range g.panes[i] {
if g.panes[i][j] == nil {
cols[j] = ""
continue
diff --git a/internal/tui/layout/overlay.go b/internal/tui/layout/overlay.go
index 87cc80e68..22f9e00fe 100644
--- a/internal/tui/layout/overlay.go
+++ b/internal/tui/layout/overlay.go
@@ -159,12 +159,7 @@ func max(a, b int) int {
return b
}
-func min(a, b int) int {
- if a < b {
- return a
- }
- return b
-}
+
type whitespace struct {
style termenv.Style