on main help sign in
small fixes
commit795b3692197acf75ff13ed8a14c9a11d4b32ec5f authorKujtim Hoxha <kujtimii.h@gmail.com> dateThu 3 Apr 2025, 17:36 (2 years ago) parentcfdd687
7 files changed+13−24
internal/llm/tools/edit.go+2−2 internal/lsp/util/edit.go+4−4 internal/lsp/watcher/watcher.go+1−1 internal/tui/components/core/button.go+3−3 internal/tui/components/repl/messages.go−6 internal/tui/layout/grid.go+2−2 internal/tui/layout/overlay.go+1−6
internal/llm/tools/edit.go+2−2
@@ -80,7 +80,7 @@ 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 == "" {
@@ -88,7 +88,7 @@ func (e *editTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
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+4−4
@@ -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+1−1
@@ -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+3−3
@@ -67,7 +67,7 @@ const (
6767// ButtonMsg is sent when a button is clicked
6868type 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−6
@@ -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
4745func (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
498493func (m *messagesCmp) Init() tea.Cmd {
499− m.timeLoaded = time.Now()
500494 return nil
501495}
502496
internal/tui/layout/grid.go+2−2
@@ -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+1−6
@@ -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
169164type whitespace struct {
170165 style termenv.Style