From e30518bf6213bb99d333f836ecaeb252f967d41e Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Tue, 12 Jan 2021 21:41:59 -0500 Subject: [PATCH] bug: Fix missing sorting arrow when for non-% mem (#389) Fixes a bug where you could make the sorting arrow disappear in the mem column if you did: 1. Go to proc widget 2. Switch to memory values from % 3. Press `m` --- CHANGELOG.md | 2 ++ Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- src/app.rs | 14 +++++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f698d7..f56404fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#386](https://github.com/ClementTsang/bottom/pull/386): Fixes `hide_table_gap` not working in the battery widget. +- [#389](https://github.com/ClementTsang/bottom/pull/389): Fixes the sorting arrow disappearing in proc widget under some cases. + ## [0.5.6] - 2020-12-17 ## Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 8e534df0..6e5ea7ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1122,9 +1122,9 @@ dependencies = [ [[package]] name = "predicates" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a" +checksum = "73dd9b7b200044694dfede9edf907c1ca19630908443e9447e624993700c6932" dependencies = [ "difference", "float-cmp", diff --git a/Cargo.toml b/Cargo.toml index db319ea2..82a7c29f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,8 +72,8 @@ heim = { version = "0.1.0-rc.1", features = ["disk", "memory"] } winapi = "0.3.9" [dev-dependencies] -assert_cmd = "~1.0" -predicates = "1" +assert_cmd = "1.0.2" +predicates = "1.0.6" [build-dependencies] clap = "2.33" diff --git a/src/app.rs b/src/app.rs index 5b2dbe90..dab753ab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1423,13 +1423,21 @@ impl App { .get_mut_widget_state(self.current_widget.widget_id) { match proc_widget_state.process_sorting_type { - processes::ProcessSorting::MemPercent => { + processes::ProcessSorting::MemPercent + | processes::ProcessSorting::Mem => { proc_widget_state.is_process_sort_descending = !proc_widget_state.is_process_sort_descending } + _ => { - proc_widget_state.process_sorting_type = - processes::ProcessSorting::MemPercent; + proc_widget_state.process_sorting_type = if proc_widget_state + .columns + .is_enabled(&processes::ProcessSorting::MemPercent) + { + processes::ProcessSorting::MemPercent + } else { + processes::ProcessSorting::Mem + }; proc_widget_state.is_process_sort_descending = true; } }