summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/command/search.rs37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/command/search.rs b/src/command/search.rs
index f8a4a1ba..2dcdecc8 100644
--- a/src/command/search.rs
+++ b/src/command/search.rs
@@ -97,6 +97,23 @@ impl State {
ago = format!(" {}", ago);
}
+ let selected_index = match self.results_state.selected() {
+ None => Span::raw(" "),
+ Some(selected) => match i.checked_sub(selected) {
+ None => Span::raw(" "),
+ Some(diff) => {
+ if 0 < diff && diff < 10 {
+ Span::styled(
+ format!(" {} ", diff),
+ Style::default().fg(Color::DarkGray),
+ )
+ } else {
+ Span::raw(" ")
+ }
+ }
+ },
+ };
+
let duration = Span::styled(
duration,
Style::default().fg(if m.exit == 0 || m.duration == -1 {
@@ -115,8 +132,14 @@ impl State {
}
}
- let spans =
- Spans::from(vec![duration, Span::raw(" "), ago, Span::raw(" "), command]);
+ let spans = Spans::from(vec![
+ selected_index,
+ duration,
+ Span::raw(" "),
+ ago,
+ Span::raw(" "),
+ command,
+ ]);
ListItem::new(spans)
})
@@ -171,6 +194,16 @@ async fn key_handler(
.map_or(app.input.clone(), |h| h.command.clone()),
);
}
+ Key::Alt(c) if ('1'..='9').contains(&c) => {
+ let c = c.to_digit(10)? as usize;
+ let i = app.results_state.selected()? + c;
+
+ return Some(
+ app.results
+ .get(i)
+ .map_or(app.input.clone(), |h| h.command.clone()),
+ );
+ }
Key::Char(c) => {
app.input.push(c);
query_results(app, search_mode, db).await.unwrap();