Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit 795b369

Browse files
committed
small fixes
1 parent cfdd687 commit 795b369

File tree

7 files changed

+13
-24
lines changed

7 files changed

+13
-24
lines changed

internal/llm/tools/edit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ func (e *editTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
8080
if err != nil {
8181
return NewTextErrorResponse(fmt.Sprintf("error creating file: %s", err)), nil
8282
}
83-
return NewTextErrorResponse(result), nil
83+
return NewTextResponse(result), nil
8484
}
8585

8686
if params.NewString == "" {
8787
result, err := deleteContent(params.FilePath, params.OldString)
8888
if err != nil {
8989
return NewTextErrorResponse(fmt.Sprintf("error deleting content: %s", err)), nil
9090
}
91-
return NewTextErrorResponse(result), nil
91+
return NewTextResponse(result), nil
9292
}
9393

9494
result, err := replaceContent(params.FilePath, params.OldString, params.NewString)

internal/lsp/util/edit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
3434
lines := strings.Split(string(content), lineEnding)
3535

3636
// Check for overlapping edits
37-
for i := 0; i < len(edits); i++ {
37+
for i, edit1 := range edits {
3838
for j := i + 1; j < len(edits); j++ {
39-
if rangesOverlap(edits[i].Range, edits[j].Range) {
39+
if rangesOverlap(edit1.Range, edits[j].Range) {
4040
return fmt.Errorf("overlapping edits detected between edit %d and %d", i, j)
4141
}
4242
}
@@ -54,7 +54,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
5454

5555
// Apply each edit
5656
for _, edit := range sortedEdits {
57-
newLines, err := applyTextEdit(lines, edit, lineEnding)
57+
newLines, err := applyTextEdit(lines, edit)
5858
if err != nil {
5959
return fmt.Errorf("failed to apply edit: %w", err)
6060
}
@@ -82,7 +82,7 @@ func applyTextEdits(uri protocol.DocumentUri, edits []protocol.TextEdit) error {
8282
return nil
8383
}
8484

85-
func applyTextEdit(lines []string, edit protocol.TextEdit, lineEnding string) ([]string, error) {
85+
func applyTextEdit(lines []string, edit protocol.TextEdit) ([]string, error) {
8686
startLine := int(edit.Range.Start.Line)
8787
endLine := int(edit.Range.End.Line)
8888
startChar := int(edit.Range.Start.Character)

internal/lsp/watcher/watcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func matchesSimpleGlob(pattern, path string) bool {
347347

348348
// Otherwise, check if any path component matches
349349
pathComponents := strings.Split(path, "/")
350-
for i := 0; i < len(pathComponents); i++ {
350+
for i := range pathComponents {
351351
subPath := strings.Join(pathComponents[i:], "/")
352352
if strings.HasSuffix(subPath, rest) {
353353
return true

internal/tui/components/core/button.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const (
6767
// ButtonMsg is sent when a button is clicked
6868
type ButtonMsg struct {
6969
ID string
70-
Payload interface{}
70+
Payload any
7171
}
7272

7373
// ButtonCmp represents a clickable button component
@@ -79,7 +79,7 @@ type ButtonCmp struct {
7979
state ButtonState
8080
variant ButtonVariant
8181
keyMap ButtonKeyMap
82-
payload interface{}
82+
payload any
8383
style lipgloss.Style
8484
hoverStyle lipgloss.Style
8585
}
@@ -107,7 +107,7 @@ func (b *ButtonCmp) WithVariant(variant ButtonVariant) *ButtonCmp {
107107
}
108108

109109
// WithPayload sets the payload sent with button events
110-
func (b *ButtonCmp) WithPayload(payload interface{}) *ButtonCmp {
110+
func (b *ButtonCmp) WithPayload(payload any) *ButtonCmp {
111111
b.payload = payload
112112
return b
113113
}

internal/tui/components/repl/messages.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"sort"
77
"strings"
8-
"time"
98

109
"github.com/charmbracelet/bubbles/key"
1110
"github.com/charmbracelet/bubbles/viewport"
@@ -41,7 +40,6 @@ type messagesCmp struct {
4140
height int
4241
focused bool
4342
cachedView string
44-
timeLoaded time.Time
4543
}
4644

4745
func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
@@ -424,9 +422,6 @@ func (m *messagesCmp) projectDiagnostics() string {
424422
}
425423

426424
if len(errorDiagnostics) == 0 && len(warnDiagnostics) == 0 && len(hintDiagnostics) == 0 && len(infoDiagnostics) == 0 {
427-
if time.Since(m.timeLoaded) < time.Second*10 {
428-
return "Loading diagnostics..."
429-
}
430425
return "No diagnostics"
431426
}
432427

@@ -496,7 +491,6 @@ func (m *messagesCmp) SetSize(width int, height int) {
496491
}
497492

498493
func (m *messagesCmp) Init() tea.Cmd {
499-
m.timeLoaded = time.Now()
500494
return nil
501495
}
502496

internal/tui/layout/grid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ func (g *gridLayout) View() string {
127127

128128
// Render each row
129129
rows := make([]string, g.rows)
130-
for i := 0; i < g.rows; i++ {
130+
for i := range g.rows {
131131
// Render each column in this row
132132
cols := make([]string, len(g.panes[i]))
133-
for j := 0; j < len(g.panes[i]); j++ {
133+
for j := range g.panes[i] {
134134
if g.panes[i][j] == nil {
135135
cols[j] = ""
136136
continue

internal/tui/layout/overlay.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ func max(a, b int) int {
159159
return b
160160
}
161161

162-
func min(a, b int) int {
163-
if a < b {
164-
return a
165-
}
166-
return b
167-
}
162+
168163

169164
type whitespace struct {
170165
style termenv.Style

0 commit comments

Comments
 (0)