From 073527612203ddcfd5a91d66f5f30c99eeb85186 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Tue, 11 Nov 2025 05:47:09 -0500 Subject: [PATCH] bug: ensure avg cpu is drawn on top in "All" mode (#1859) * bug: ensure avg cpu is drawn on top * changelog --- CHANGELOG.md | 10 ++++++++++ src/canvas/widgets/cpu_graph.rs | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf5aa220..f271dcaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,16 @@ That said, these are more guidelines rather than hardset rules, though the proje ### Features +### Bug Fixes + +- [#1859](https://github.com/ClementTsang/bottom/pull/1859): Ensure average CPU is drawn on top in "All" mode. + +### Other + +## [0.11.3] - 2025-11-06 + +### Features + - [#1812](https://github.com/ClementTsang/bottom/pull/1812): Add `free_arc` option to subtract ARC from total memory usage. ### Bug Fixes diff --git a/src/canvas/widgets/cpu_graph.rs b/src/canvas/widgets/cpu_graph.rs index 06e82706..973a0634 100644 --- a/src/canvas/widgets/cpu_graph.rs +++ b/src/canvas/widgets/cpu_graph.rs @@ -132,10 +132,8 @@ impl Painter { .iter() .enumerate() .map(|(itx, values)| { - let style = if show_avg_cpu && itx == AVG_POSITION { + let style = if show_avg_cpu && itx == 0 { self.styles.avg_cpu_colour - } else if itx == ALL_POSITION { - self.styles.all_cpu_colour } else { self.styles.cpu_colour_styles [(itx - show_avg_offset) % self.styles.cpu_colour_styles.len()] @@ -147,6 +145,7 @@ impl Painter { .collect() } else if let Some(CpuData { .. }) = cpu_entries.get(current_scroll_position - 1) { // We generally subtract one from current scroll position because of the all entry. + // TODO: Do this a bit better (e.g. we can just do if let Some(_) = cpu_points.get()) let style = if show_avg_cpu && current_scroll_position == AVG_POSITION { self.styles.avg_cpu_colour