Skip to content

Commit c729e22

Browse files
committed
Fix EXA_GRID_ROWS not working in some cases
1 parent 2aaead1 commit c729e22

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/output/grid_details.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,21 @@ impl<'a> Render<'a> {
174174
};
175175

176176
if the_grid_fits {
177-
if column_count == file_names.len() {
178-
return Some((grid, column_count));
179-
} else {
180-
last_working_grid = grid;
181-
}
182-
} else {
183-
// If we’ve figured out how many columns can fit in the user’s
184-
// terminal, and it turns out there aren’t enough rows to
185-
// make it worthwhile, then just resort to the lines view.
177+
last_working_grid = grid;
178+
}
179+
180+
if !the_grid_fits || column_count == file_names.len() {
181+
let last_column_count = if the_grid_fits { column_count } else { column_count - 1 };
182+
// If we’ve figured out how many columns can fit in the user’s terminal,
183+
// and it turns out there aren’t enough rows to make it worthwhile
184+
// (according to EXA_GRID_ROWS), then just resort to the lines view.
186185
if let RowThreshold::MinimumRows(thresh) = self.row_threshold {
187-
if last_working_grid.fit_into_columns(column_count - 1).row_count() < thresh {
186+
if last_working_grid.fit_into_columns(last_column_count).row_count() < thresh {
188187
return None;
189188
}
190189
}
191190

192-
return Some((last_working_grid, column_count - 1));
191+
return Some((last_working_grid, last_column_count));
193192
}
194193
}
195194

0 commit comments

Comments
 (0)