Skip to content

Commit

Permalink
Fix grid output when one file is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Sep 23, 2024
1 parent f4487af commit d489aa4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/output/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Grid {

/// Render the grid to STDOUT.
pub fn render(&self, _app_const: &AppConst) {
let max_width = self.entries.iter().map(strip_image).map(len).max();
let mut max_width = self.entries.iter().map(strip_image).map(len).max();
let max_cols = self.columns(max_width);

let entry_len = self.entries.len();
Expand All @@ -45,7 +45,12 @@ impl Grid {
let rows = (entry_len as f64 / max_cols as f64).ceil() as usize;
let cols = (entry_len as f64 / rows as f64).ceil() as usize;

if PLS.args.down {
if cols == 1 {
// If there is only one column, we don't need to equalise width.
max_width = None;
}

if cols > 1 && PLS.args.down {
self.print(&self.down(rows), cols, max_width);
} else {
self.print(&self.entries, cols, max_width);
Expand Down

0 comments on commit d489aa4

Please sign in to comment.