Browse Source

fix: clippy lint and add option to grid-details

PThorpe92 2 years ago
parent
commit
a500254e14
2 changed files with 20 additions and 10 deletions
  1. 1 1
      src/output/grid.rs
  2. 19 9
      src/output/grid_details.rs

+ 1 - 1
src/output/grid.rs

@@ -60,7 +60,7 @@ impl<'a> Render<'a> {
             let space_filename_offset = match self.file_style.quote_style {
                 QuoteStyle::QuoteSpaces if file.name.contains(' ') => 2,
                 QuoteStyle::NoQuotes => 0,
-                _ => 0, // Default case
+                QuoteStyle::QuoteSpaces => 0, // Default case
             };
             let contents = filename.paint();
             let width = match (

+ 19 - 9
src/output/grid_details.rs

@@ -19,6 +19,8 @@ use crate::output::table::{Options as TableOptions, Row as TableRow, Table};
 use crate::output::tree::{TreeDepth, TreeParams};
 use crate::theme::Theme;
 
+use super::file_name::QuoteStyle;
+
 #[derive(PartialEq, Eq, Debug)]
 pub struct Options {
     pub grid: GridOptions,
@@ -162,16 +164,24 @@ impl<'a> Render<'a> {
             .map(|file| {
                 let filename = self.file_style.for_file(file, self.theme);
                 let contents = filename.paint();
-                let space_filename_offset = if file.name.contains(' ') || file.name.contains('\'') {
-                    2
-                } else {
-                    0
+                let space_filename_offset = match self.file_style.quote_style {
+                    QuoteStyle::QuoteSpaces if file.name.contains(' ') => 2,
+                    QuoteStyle::NoQuotes => 0,
+                    QuoteStyle::QuoteSpaces => 0, // Default case
                 };
-                #[rustfmt::skip]
-                let width = match (filename.options.embed_hyperlinks, filename.options.show_icons) {
-                    (EmbedHyperlinks::On, ShowIcons::Automatic(spacing)) => filename.bare_width() + 1 + (spacing as usize) + space_filename_offset,
-                    (EmbedHyperlinks::On, ShowIcons::Always(spacing)) => filename.bare_width() + 1 + (spacing as usize) + space_filename_offset,
-                    (EmbedHyperlinks::On, ShowIcons::Never) => filename.bare_width() + space_filename_offset,
+                let width = match (
+                    filename.options.embed_hyperlinks,
+                    filename.options.show_icons,
+                ) {
+                    (EmbedHyperlinks::On, ShowIcons::Automatic(spacing)) => {
+                        filename.bare_width() + 1 + (spacing as usize) + space_filename_offset
+                    }
+                    (EmbedHyperlinks::On, ShowIcons::Always(spacing)) => {
+                        filename.bare_width() + 1 + (spacing as usize) + space_filename_offset
+                    }
+                    (EmbedHyperlinks::On, ShowIcons::Never) => {
+                        filename.bare_width() + space_filename_offset
+                    }
                     (EmbedHyperlinks::Off, _) => *contents.width(),
                 };