Skip to content

Commit

Permalink
number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cartercanedy committed Sep 28, 2024
1 parent 0501225 commit 89928b0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tui/src/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ pub struct ConfirmPrompt {

impl ConfirmPrompt {
pub fn new(names: &[&str]) -> Self {
let max_count_str = format!("{}", names.len());
let names = names
.iter()
.zip(1..)
.map(|(name, n)| format!("{n}. {name}"))
.map(|(name, n)| {
let count_str = format!("{n}");
let space_str = (0..(max_count_str.len() - count_str.len()))
.map(|_| ' ')
.collect::<String>();
format!("{space_str}{n}. {name}")
})
.collect();

Self {
Expand Down

0 comments on commit 89928b0

Please sign in to comment.