Detailed changes
@@ -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]
}
@@ -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:"-"`
@@ -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()
@@ -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 {
@@ -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)