diff --git a/youtui/src/app/ui/browser.rs b/youtui/src/app/ui/browser.rs index a7655d9..6b885b2 100644 --- a/youtui/src/app/ui/browser.rs +++ b/youtui/src/app/ui/browser.rs @@ -429,6 +429,7 @@ impl Browser { async fn search(&mut self) { self.artist_list.close_search(); let search_query = self.artist_list.search.get_text().to_string(); + self.artist_list.clear_text(); let handler = |this: &mut Self, results| match results { Ok(artists) => { diff --git a/youtui/src/app/ui/browser/artistalbums/artistsearch.rs b/youtui/src/app/ui/browser/artistalbums/artistsearch.rs index 36b5f10..43ed8b8 100644 --- a/youtui/src/app/ui/browser/artistalbums/artistsearch.rs +++ b/youtui/src/app/ui/browser/artistalbums/artistsearch.rs @@ -109,8 +109,10 @@ impl TextHandler for SearchBlock { } fn replace_text(&mut self, text: impl Into) { self.search_contents.set_text(text); + self.search_contents.move_to_line_end(false); } fn clear_text(&mut self) -> bool { + self.search_suggestions.clear(); self.search_contents.clear() } fn handle_event_repr(&mut self, event: &crossterm::event::Event) -> bool { @@ -180,7 +182,7 @@ impl SearchBlock { ); // Safe - clamped above // Clone is ok here as we want to duplicate the search suggestion. - self.search_contents.set_text( + self.replace_text( self.search_suggestions[self.suggestions_cur.expect("Set to non-None value above")] .get_text(), );