From 5e23ecdb4da522af4db2251b96d92e0c368389df Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 10 Feb 2026 11:08:36 -0300 Subject: [PATCH] chore: run `modernize` --- internal/agent/tools/search.go | 4 ++-- internal/config/config.go | 4 ++-- internal/csync/value_test.go | 6 ++---- internal/shell/shell.go | 4 ++-- internal/ui/model/chat.go | 5 +---- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/internal/agent/tools/search.go b/internal/agent/tools/search.go index 9df7be8764ab952a23f25d624f72748696a86aac..8d21162001e129f2f614e56b1288bad89904f4c0 100644 --- a/internal/agent/tools/search.go +++ b/internal/agent/tools/search.go @@ -172,8 +172,8 @@ func getTextContent(n *html.Node) string { func cleanDuckDuckGoURL(rawURL string) string { if strings.HasPrefix(rawURL, "//duckduckgo.com/l/?uddg=") { - if idx := strings.Index(rawURL, "uddg="); idx != -1 { - encoded := rawURL[idx+5:] + if _, after, ok := strings.Cut(rawURL, "uddg="); ok { + encoded := after if ampIdx := strings.Index(encoded, "&"); ampIdx != -1 { encoded = encoded[:ampIdx] } diff --git a/internal/config/config.go b/internal/config/config.go index 07608f4ff59abda3347b032673b9bb2c3705c2e5..fd76e4f8a8639ececc8e8452c75bc6178e4b8cff 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -350,7 +350,7 @@ type Agent struct { } type Tools struct { - Ls ToolLs `json:"ls,omitempty"` + Ls ToolLs `json:"ls"` } type ToolLs struct { @@ -383,7 +383,7 @@ type Config struct { Permissions *Permissions `json:"permissions,omitempty" jsonschema:"description=Permission settings for tool usage"` - Tools Tools `json:"tools,omitempty" jsonschema:"description=Tool configurations"` + Tools Tools `json:"tools" jsonschema:"description=Tool configurations"` Agents map[string]Agent `json:"-"` diff --git a/internal/csync/value_test.go b/internal/csync/value_test.go index 3fa41d85144ea9373c7d440238c0321f52286330..2d0243a3b0ae8f71802469496c35b5d4a50d260b 100644 --- a/internal/csync/value_test.go +++ b/internal/csync/value_test.go @@ -83,11 +83,9 @@ func TestValue_ConcurrentAccess(t *testing.T) { // Concurrent readers. for range 100 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { _ = v.Get() - }() + }) } wg.Wait() diff --git a/internal/shell/shell.go b/internal/shell/shell.go index ced8da26ed4e837b08e66152e9aafb2cc029c0d1..d8dde82a0077d3be5cd19c2714e5a1a5097d015c 100644 --- a/internal/shell/shell.go +++ b/internal/shell/shell.go @@ -207,8 +207,8 @@ func splitArgsFlags(parts []string) (args []string, flags []string) { if strings.HasPrefix(part, "-") { // Extract flag name before '=' if present flag := part - if idx := strings.IndexByte(part, '='); idx != -1 { - flag = part[:idx] + if before, _, ok := strings.Cut(part, "="); ok { + flag = before } flags = append(flags, flag) } else { diff --git a/internal/ui/model/chat.go b/internal/ui/model/chat.go index 00a17ecfc5042dd42f4d24682b135667d1345386..a424bd1053134496688d422b0ee19aef3a0b4e35 100644 --- a/internal/ui/model/chat.go +++ b/internal/ui/model/chat.go @@ -745,10 +745,7 @@ func (m *Chat) selectWord(itemIdx, x, itemY int) { // Adjust x for the item's left padding (border + padding) to get content column. // The mouse x is in viewport space, but we need content space for boundary detection. offset := chat.MessageLeftPaddingTotal - contentX := x - offset - if contentX < 0 { - contentX = 0 - } + contentX := max(x-offset, 0) line := ansi.Strip(lines[itemY]) startCol, endCol := findWordBoundaries(line, contentX)