Skip to content

Commit

Permalink
fix: Display offset for filenames with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeboehm committed Oct 20, 2023
1 parent 1a508be commit 0c383ce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/output/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,28 @@ impl<'a> Render<'a> {
0
};

let mut additionnal_chars = 0;
if file.name.contains(' ') {
// If the filename contains spaces the output adds quotes
// around the name
additionnal_chars += 2;
}

let contents = filename.paint();
let width = match (
filename.options.embed_hyperlinks,
filename.options.show_icons,
) {
#[rustfmt::skip]
(EmbedHyperlinks::On, ShowIcons::Always(spacing)
| ShowIcons::Automatic(spacing)) => filename.bare_width() + classification_width + 1 + (spacing as usize),
| ShowIcons::Automatic(spacing)) => filename.bare_width() + classification_width + 1 + (spacing as usize) + additionnal_chars,
(EmbedHyperlinks::On, ShowIcons::Never) => {
filename.bare_width() + classification_width
}
(
EmbedHyperlinks::Off,
ShowIcons::Always(spacing) | ShowIcons::Automatic(spacing),
) => filename.bare_width() + 1 + (spacing as usize),
) => filename.bare_width() + 1 + (spacing as usize) + additionnal_chars,
(EmbedHyperlinks::Off, _) => *contents.width(),
};

Expand Down

0 comments on commit 0c383ce

Please sign in to comment.