This commit is contained in:
Ellie Huxtable 2023-04-10 19:53:51 +01:00
parent d15fcd6fe6
commit 242b795e8e
2 changed files with 12 additions and 5 deletions

View File

@ -555,7 +555,7 @@ mod test {
filter_mode: FilterMode,
query: &str,
expected: usize,
) -> Result<Vec<History>> {
) -> Result<Vec<HistoryResult>> {
let context = Context {
hostname: "test:host".to_string(),
session: "beepboopiamasession".to_string(),
@ -579,8 +579,12 @@ mod test {
expected,
"query \"{}\", commands: {:?}",
query,
results.iter().map(|a| &a.command).collect::<Vec<&String>>()
results
.iter()
.map(|a| &a.history.command)
.collect::<Vec<&String>>()
);
Ok(results)
}
@ -594,7 +598,7 @@ mod test {
let results = assert_search_eq(db, mode, filter_mode, query, expected_commands.len())
.await
.unwrap();
let commands: Vec<&str> = results.iter().map(|a| a.command.as_str()).collect();
let commands: Vec<&str> = results.iter().map(|a| a.history.command.as_str()).collect();
assert_eq!(commands, expected_commands);
}

View File

@ -308,8 +308,10 @@ impl State {
let preview = self.build_preview(results, compact, preview_width, chunks[3].width.into());
f.render_widget(preview, chunks[3]);
let selected_history = results[self.results_state.selected()].clone();
self.render_bar(f, &selected_history, chunks[4]);
if results.len() > 0 {
let selected_history = results[self.results_state.selected()].clone();
self.render_bar(f, &selected_history, chunks[4]);
}
let extra_width = UnicodeWidthStr::width(self.search.input.substring());
@ -390,6 +392,7 @@ impl State {
.style(Style::default().bg(Color::White).fg(Color::Black));
f.render_widget(directory, bar[0]);
f.render_widget(count, bar[1]);
}
fn build_input(&mut self, compact: bool, chunk_width: usize) -> Paragraph {