Преглед на файлове

refactor(ui/chat): optimize search picker, add docs

- Replace fmt.Sprintf with string concatenation in update()
- Add file-level doc comment and resetBrowse comment

Fixes: COMP #7, COMP #12, COMP #17

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
claude преди 1 месец
родител
ревизия
dfbcf30b5b
променени са 1 файла, в които са добавени 5 реда и са изтрити 3 реда
  1. 5 3
      internal/ui/chat/search_picker.go

+ 5 - 3
internal/ui/chat/search_picker.go

@@ -1,8 +1,9 @@
+// search_picker.go implements a fuzzy search overlay for messages in the
+// current channel. Opened via the search keybind, it lets users filter
+// messages by author name and content, then jump to the selected message.
 package chat
 
 import (
-	"fmt"
-
 	"github.com/ayn2op/discordo/internal/config"
 	"github.com/ayn2op/tview"
 	"github.com/ayn2op/tview/help"
@@ -26,6 +27,7 @@ func newSearchPicker(cfg *config.Config, chatView *Model) *searchPicker {
 	return sp
 }
 
+// resetBrowse starts the search picker in input mode so users can type a query immediately.
 func (sp *searchPicker) resetBrowse() { sp.browseMode = false }
 
 func (sp *searchPicker) HandleEvent(event tview.Event) tview.Command {
@@ -60,7 +62,7 @@ func (sp *searchPicker) update() {
 		}
 		items = append(items, picker.Item{
 			Text:       text,
-			FilterText: fmt.Sprintf("%s %s", msg.Author.DisplayOrUsername(), msg.Content),
+			FilterText: msg.Author.DisplayOrUsername() + " " + msg.Content,
 			Reference:  i,
 		})
 	}