mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-15 15:18:45 +00:00
Correctly update num_chars
This commit is contained in:
parent
7da80c946d
commit
352c29e1e0
@ -590,12 +590,12 @@ fn run() -> Result<()> {
|
|||||||
let mut extension = lang.file_extensions.iter().peekable();
|
let mut extension = lang.file_extensions.iter().peekable();
|
||||||
while let Some(word) = extension.next() {
|
while let Some(word) = extension.next() {
|
||||||
// If we can't fit this word in, then create a line break and align it in.
|
// If we can't fit this word in, then create a line break and align it in.
|
||||||
if word.len() + num_chars + comma_separator.len() >= desired_width {
|
if num_chars + word.len() + comma_separator.len() >= desired_width {
|
||||||
num_chars = 0;
|
num_chars = 0;
|
||||||
print!("\n{:width$}{}", "", separator, width = longest);
|
print!("\n{:width$}{}", "", separator, width = longest);
|
||||||
}
|
}
|
||||||
|
|
||||||
num_chars += word.len();
|
num_chars += word.len() + comma_separator.len();
|
||||||
print!("{}", word);
|
print!("{}", word);
|
||||||
if extension.peek().is_some() {
|
if extension.peek().is_some() {
|
||||||
print!("{}", comma_separator);
|
print!("{}", comma_separator);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user