Skip to content

Commit

Permalink
Fix EXA_GRID_ROWS not working in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ariasuni committed Apr 9, 2021
1 parent 2aaead1 commit c729e22
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/output/grid_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,21 @@ impl<'a> Render<'a> {
};

if the_grid_fits {
if column_count == file_names.len() {
return Some((grid, column_count));
} else {
last_working_grid = grid;
}
} else {
// If we’ve figured out how many columns can fit in the user’s
// terminal, and it turns out there aren’t enough rows to
// make it worthwhile, then just resort to the lines view.
last_working_grid = grid;
}

if !the_grid_fits || column_count == file_names.len() {
let last_column_count = if the_grid_fits { column_count } else { column_count - 1 };
// If we’ve figured out how many columns can fit in the user’s terminal,
// and it turns out there aren’t enough rows to make it worthwhile
// (according to EXA_GRID_ROWS), then just resort to the lines view.
if let RowThreshold::MinimumRows(thresh) = self.row_threshold {
if last_working_grid.fit_into_columns(column_count - 1).row_count() < thresh {
if last_working_grid.fit_into_columns(last_column_count).row_count() < thresh {
return None;
}
}

return Some((last_working_grid, column_count - 1));
return Some((last_working_grid, last_column_count));
}
}

Expand Down

0 comments on commit c729e22

Please sign in to comment.