ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: colorize choices of prev/next commits

This commit is contained in:
Yuya Nishihara 2024-01-23 10:37:47 +09:00
parent d168fd2b09
commit 566713bf6b

View file

@ -70,18 +70,17 @@ pub fn choose_commit<'a>(
commits: &'a [Commit],
) -> Result<&'a Commit, CommandError> {
writeln!(ui.stdout(), "ambiguous {cmd} commit, choose one to target:")?;
let mut formatter = ui.stdout_formatter();
let mut choices: Vec<String> = Default::default();
for (i, commit) in commits.iter().enumerate() {
writeln!(
ui.stdout(),
"{}: {}",
i + 1,
workspace_command.format_commit_summary(commit)
)?;
write!(formatter, "{}: ", i + 1)?;
workspace_command.write_commit_summary(formatter.as_mut(), commit)?;
writeln!(formatter)?;
choices.push(format!("{}", i + 1));
}
writeln!(ui.stdout(), "q: quit the prompt")?;
writeln!(formatter, "q: quit the prompt")?;
choices.push("q".to_string());
drop(formatter);
let choice = ui.prompt_choice(
"enter the index of the commit you want to target",