refactor: use only multi suggest

This commit is contained in:
iff 2025-02-12 18:26:41 +01:00
parent e9cf81cc42
commit 8269ee4197

View file

@ -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();
} }