Detailed changes
@@ -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)
@@ -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)
@@ -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
@@ -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
}
@@ -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
}
@@ -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
@@ -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