feat(tui): show a result's file name and folder in columns of their own
The results list held the whole shared path in one column, so a search was read through its folder: every row began with the same peer prefix and the file name, the part being searched for, sat off the right edge. Split the column at the last separator, the file name first with the larger share of the width and the folder dimmed beside it, so names line up and read at a glance. The one scroll offset moves both columns together, and $ runs to the end of whichever overflows further. The website's mock of the pane follows. Suggested in #55.
This commit is contained in:
@@ -1158,8 +1158,9 @@ mod tests {
|
||||
let mut tui = with_session(TalkativeSession::default());
|
||||
tui.state.results_items = results(n);
|
||||
tui.state.focused_pane = FocusedPane::Results;
|
||||
// 88 cells wide gives the name column 11 cells and the folder 7.
|
||||
tui.state.results_pane_area =
|
||||
Some(ratatui::layout::Rect::new(0, 0, 80, 13));
|
||||
Some(ratatui::layout::Rect::new(0, 0, 88, 13));
|
||||
tui
|
||||
}
|
||||
|
||||
@@ -1273,6 +1274,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scrolling_runs_to_the_end_of_the_folder_when_it_is_the_longer() {
|
||||
let mut tui = results_tui(3);
|
||||
tui.state.results_items[1].filename =
|
||||
format!("{}\\short.mp3", "f".repeat(20));
|
||||
tui.state.results_table_state.select(Some(1));
|
||||
press(&mut tui, KeyCode::Char('$'));
|
||||
assert_eq!(tui.state.results_name_offset, 14);
|
||||
press(&mut tui, KeyCode::Char('l'));
|
||||
assert_eq!(tui.state.results_name_offset, 14, "stops at the end");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn picking_another_search_starts_its_results_unscrolled() {
|
||||
let mut tui = results_tui(3);
|
||||
|
||||
Reference in New Issue
Block a user