Skip to content

Commit

Permalink
Fix - search suggestions stay after searching, cursor doesnt move to …
Browse files Browse the repository at this point in the history
…end after selecting
  • Loading branch information
nick42d committed Nov 22, 2024
1 parent 1ae6431 commit 1cf4620
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions youtui/src/app/ui/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion youtui/src/app/ui/browser/artistalbums/artistsearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ impl TextHandler for SearchBlock {
}
fn replace_text(&mut self, text: impl Into<String>) {
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 {
Expand Down Expand Up @@ -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(),
);
Expand Down

0 comments on commit 1cf4620

Please sign in to comment.