diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-11-29 14:06:05 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-11-29 14:06:05 +0300 |
| commit | c1b689a4b5cced7558563412189c0a00108cc249 (patch) | |
| tree | 231916a0d04cf8321d11da2c6a7ed548312ebcdf /tui.go | |
| parent | 869e743248f82101663631469a9a6b355c4b3095 (diff) | |
Enha: empty string search to cancel
Diffstat (limited to 'tui.go')
| -rw-r--r-- | tui.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -860,18 +860,24 @@ func init() { }) // searchField = tview.NewInputField(). - SetPlaceholder("Search... (Enter: search, Esc: cancel)"). + SetPlaceholder("Search... (Enter: search)"). SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEnter { term := searchField.GetText() - if term != "" { + if term == "" { + // If the search term is empty, cancel the search + hideSearchBar() + searchResults = nil + searchResultLengths = nil + textView.SetText(chatToText(cfg.ShowSys)) + colorText() + return + } else { performSearch(term) // Keep focus on textView after search app.SetFocus(textView) + hideSearchBar() } - hideSearchBar() - } else if key == tcell.KeyEscape { - hideSearchBar() } }) searchField.SetBorder(true).SetTitle("Search") |
