From c3d1665fa6cce852bff61c1d3b6a592f43e72d07 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 16 Apr 2026 19:12:31 +0530 Subject: [PATCH] run go modernizer --- kittens/command_palette/main.go | 4 ++-- kittens/command_palette/main_test.go | 4 ++-- tools/watch/api_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kittens/command_palette/main.go b/kittens/command_palette/main.go index ae669f1c9..d26086686 100644 --- a/kittens/command_palette/main.go +++ b/kittens/command_palette/main.go @@ -142,8 +142,8 @@ func bestWordMatch(queryToken string, words []wordToken, colText string) (score // Compound token: try exact substring match in the column text colLower := strings.ToLower(colText) - if idx := strings.Index(colLower, queryToken); idx != -1 { - runeIdx := len([]rune(colLower[:idx])) + if before, _, ok := strings.Cut(colLower, queryToken); ok { + runeIdx := len([]rune(before)) qRuneLen := len([]rune(queryToken)) subParts := strings.FieldsFunc(queryToken, isWordDelimiter) return 4 * len(subParts), runeRange(runeIdx, runeIdx+qRuneLen) diff --git a/kittens/command_palette/main_test.go b/kittens/command_palette/main_test.go index be2293d29..1ce25e3a4 100644 --- a/kittens/command_palette/main_test.go +++ b/kittens/command_palette/main_test.go @@ -23,8 +23,8 @@ func testBinding(key, action, help string) Binding { // Action. Action is derived as the first word of actionDisplay. func testMouseBinding(key, actionDisplay string) Binding { action := actionDisplay - if idx := strings.IndexByte(actionDisplay, ' '); idx >= 0 { - action = actionDisplay[:idx] + if before, _, ok := strings.Cut(actionDisplay, " "); ok { + action = before } return Binding{ Key: key, diff --git a/tools/watch/api_test.go b/tools/watch/api_test.go index 76544f251..d28cf289b 100644 --- a/tools/watch/api_test.go +++ b/tools/watch/api_test.go @@ -245,7 +245,7 @@ func TestWatchForConfigChangesDebounce(t *testing.T) { // Write to the file several times rapidly within the debounce window. // The fswatcher debouncer drops events that occur within the cooldown period // after the first event, so only the first write should produce an action call. - for i := 0; i < 5; i++ { + for i := range 5 { write_file(t, main_conf, fmt.Sprintf("font_size %d\n", 12+i)) time.Sleep(20 * time.Millisecond) }