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 bb8a9ef
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/output/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,30 @@ impl<'a> Render<'a> {
0
};

let space_filename_offset = if file.name.contains(' ') { 2 } else { 0 };

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),
(EmbedHyperlinks::On, ShowIcons::Never) => {
filename.bare_width() + classification_width
}
(
EmbedHyperlinks::On,
ShowIcons::Always(spacing) | ShowIcons::Automatic(spacing)
) => filename.bare_width() + classification_width + 1 + (spacing as usize) + space_filename_offset,
(
EmbedHyperlinks::On,
ShowIcons::Never
) => filename.bare_width() + classification_width + space_filename_offset,
(
EmbedHyperlinks::Off,
ShowIcons::Always(spacing) | ShowIcons::Automatic(spacing),
) => filename.bare_width() + 1 + (spacing as usize),
(EmbedHyperlinks::Off, _) => *contents.width(),
) => filename.bare_width() + 1 + (spacing as usize) + space_filename_offset,
(
EmbedHyperlinks::Off,
_
) => *contents.width(),
};

grid.add(tg::Cell {
Expand Down

0 comments on commit bb8a9ef

Please sign in to comment.