Skip to content

Commit

Permalink
fix: implement EZA_GRID_ROWS grid details view minimum rows threshold
Browse files Browse the repository at this point in the history
Grid details view had been prevented only by
console width being unavailable.

This changeset implements `EZA_GRID_ROWS`
as secondary grid details inhibitor, preventing
grid details view if the minimum rows threshold
is not reached by grid which would be rendered.

Fixes complaint at eza-community#66 (comment)
  • Loading branch information
LeoniePhiline authored and cafkafk committed Aug 7, 2024
1 parent 6cbb5ba commit 42e1e07
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/output/grid_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ impl<'a> Render<'a> {

let cells = rows
.into_iter()
.zip(self.files)
.zip(&self.files)
.map(|(row, file)| {
let filename = self
.file_style
.for_file(&file, self.theme)
.for_file(file, self.theme)
.paint()
.strings()
.to_string();
Expand Down Expand Up @@ -178,6 +178,41 @@ impl<'a> Render<'a> {
},
);

// If a minimum grid rows threshold has been set
// via the `EZA_GRID_ROWS` environment variable
// and the grid is going to get rendered with fewer rows,
// then render a details list view instead.
if let RowThreshold::MinimumRows(minimum_rows) = self.row_threshold {
if grid.row_count() < minimum_rows {
let Self {
dir,
files,
theme,
file_style,
details: opts,
filter,
git_ignoring,
git,
git_repos,
..
} = self;

let r = DetailsRender {
dir,
files,
theme,
file_style,
opts,
recurse: None,
filter,
git_ignoring,
git,
git_repos,
};
return r.render(w);
}
}

if self.details.header {
let row = table.header_row();
let name = TextCell::paint_str(self.theme.ui.header, "Name")
Expand Down

0 comments on commit 42e1e07

Please sign in to comment.