mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
refactor: use only multi suggest
This commit is contained in:
parent
e9cf81cc42
commit
8269ee4197
1 changed files with 35 additions and 45 deletions
|
|
@ -83,16 +83,7 @@ pub fn select_candidate(data: &mut Data) {
|
||||||
let candidates = &data.candidates;
|
let candidates = &data.candidates;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
eprintln!("candidates: {candidates:?}");
|
eprintln!("candidates: {candidates:?}");
|
||||||
if candidates.len() == 1 {
|
|
||||||
let suggestion = candidates[0].to_string();
|
|
||||||
let highlighted = highlight_difference(data, &suggestion).unwrap();
|
|
||||||
let confirm = format!("[{}]", t!("confirm-yes")).green();
|
|
||||||
eprintln!("{}\n", highlighted);
|
|
||||||
eprintln!("{}: {} {}", t!("confirm"), confirm, "[Ctrl+C]".red());
|
|
||||||
std::io::stdin().read_line(&mut String::new()).unwrap();
|
|
||||||
data.update_suggest(&suggestion);
|
|
||||||
data.expand_suggest();
|
|
||||||
} else {
|
|
||||||
let mut highlight_candidates = candidates
|
let mut highlight_candidates = candidates
|
||||||
.iter()
|
.iter()
|
||||||
.map(|candidate| highlight_difference(data, candidate).unwrap())
|
.map(|candidate| highlight_difference(data, candidate).unwrap())
|
||||||
|
|
@ -115,7 +106,7 @@ pub fn select_candidate(data: &mut Data) {
|
||||||
.bold()
|
.bold()
|
||||||
.blue();
|
.blue();
|
||||||
let confirm = format!("[{}]", t!("confirm-yes")).green();
|
let confirm = format!("[{}]", t!("confirm-yes")).green();
|
||||||
let hint = format!("{} {} {}", "[↑/↓]".blue(), confirm, "[Ctrl+C]".red());
|
let hint = format!("{} {} {}", "[↑/↓/j/k]".blue(), confirm, "[ESC]".red());
|
||||||
eprintln!("{}", msg);
|
eprintln!("{}", msg);
|
||||||
eprintln!("{}", hint);
|
eprintln!("{}", hint);
|
||||||
|
|
||||||
|
|
@ -130,7 +121,6 @@ pub fn select_candidate(data: &mut Data) {
|
||||||
let suggestion = candidates[pos].to_string();
|
let suggestion = candidates[pos].to_string();
|
||||||
data.update_suggest(&suggestion);
|
data.update_suggest(&suggestion);
|
||||||
data.expand_suggest();
|
data.expand_suggest();
|
||||||
}
|
|
||||||
|
|
||||||
data.candidates.clear();
|
data.candidates.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue