Skip to content

Commit

Permalink
fix: add extra row for basic cpu widget if using avg row on cores % 4…
Browse files Browse the repository at this point in the history
… != 0
  • Loading branch information
zebp committed Aug 18, 2024
1 parent 5a00998 commit aa5a89a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,12 @@ impl Painter {
// This fixes #397, apparently if the height is 1, it can't render the CPU
// bars...
let cpu_height = {
let c =
(actual_cpu_data_len / 4) as u16 + u16::from(actual_cpu_data_len % 4 != 0);
let c = (actual_cpu_data_len / 4) as u16
+ u16::from(actual_cpu_data_len % 4 != 0)
+ u16::from(
app_state.app_config_fields.dedicated_average_row
&& actual_cpu_data_len.saturating_sub(1) % 4 != 0,
);

if c <= 1 {
1
Expand Down
1 change: 1 addition & 0 deletions src/canvas/widgets/cpu_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl Painter {

if let Some(avg) = avg_data {
let (outer, inner, ratio, style) = self.cpu_info(&avg);

let [cores_loc, mut avg_loc] =
Layout::vertical([Constraint::Min(0), Constraint::Length(1)]).areas(draw_loc);

Expand Down

0 comments on commit aa5a89a

Please sign in to comment.