mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-29 07:30:21 +00:00
fix: Fixes count being sortable, but nothing occuring (#224)
Fixes sorting by count being available, but doing nothing. This fix makes it sortable.
This commit is contained in:
parent
cc87fa8e4a
commit
0d8572c692
3 changed files with 24 additions and 11 deletions
|
@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- [#215](https://github.com/ClementTsang/bottom/pull/215): Add labels to Linux temperature values.
|
- [#215](https://github.com/ClementTsang/bottom/pull/215): Add labels to Linux temperature values.
|
||||||
|
|
||||||
|
- [#224](https://github.com/ClementTsang/bottom/pull/224): Implements sorting by count. It previously did absolutely nothing.
|
||||||
|
|
||||||
## [0.4.7] - 2020-08-26
|
## [0.4.7] - 2020-08-26
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
13
src/app.rs
13
src/app.rs
|
@ -268,6 +268,19 @@ impl App {
|
||||||
// Toggles process widget grouping state
|
// Toggles process widget grouping state
|
||||||
proc_widget_state.is_grouped = !(proc_widget_state.is_grouped);
|
proc_widget_state.is_grouped = !(proc_widget_state.is_grouped);
|
||||||
|
|
||||||
|
// Forcefully switch off column if we were on it...
|
||||||
|
if (proc_widget_state.is_grouped
|
||||||
|
&& proc_widget_state.process_sorting_type
|
||||||
|
== data_harvester::processes::ProcessSorting::Pid)
|
||||||
|
|| (!proc_widget_state.is_grouped
|
||||||
|
&& proc_widget_state.process_sorting_type
|
||||||
|
== data_harvester::processes::ProcessSorting::Count)
|
||||||
|
{
|
||||||
|
proc_widget_state.process_sorting_type =
|
||||||
|
data_harvester::processes::ProcessSorting::CpuPercent; // Go back to default, negate PID for group
|
||||||
|
proc_widget_state.process_sorting_reverse = true;
|
||||||
|
}
|
||||||
|
|
||||||
proc_widget_state
|
proc_widget_state
|
||||||
.columns
|
.columns
|
||||||
.column_mapping
|
.column_mapping
|
||||||
|
|
20
src/lib.rs
20
src/lib.rs
|
@ -510,16 +510,6 @@ pub fn update_final_process_list(app: &mut App, widget_id: u64) {
|
||||||
|
|
||||||
// Quick fix for tab updating the table headers
|
// Quick fix for tab updating the table headers
|
||||||
if let Some(proc_widget_state) = app.proc_state.get_mut_widget_state(widget_id) {
|
if let Some(proc_widget_state) = app.proc_state.get_mut_widget_state(widget_id) {
|
||||||
if let data_harvester::processes::ProcessSorting::Pid =
|
|
||||||
proc_widget_state.process_sorting_type
|
|
||||||
{
|
|
||||||
if proc_widget_state.is_grouped {
|
|
||||||
proc_widget_state.process_sorting_type =
|
|
||||||
data_harvester::processes::ProcessSorting::CpuPercent; // Go back to default, negate PID for group
|
|
||||||
proc_widget_state.process_sorting_reverse = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut resulting_processes = filtered_process_data;
|
let mut resulting_processes = filtered_process_data;
|
||||||
sort_process_data(&mut resulting_processes, proc_widget_state);
|
sort_process_data(&mut resulting_processes, proc_widget_state);
|
||||||
|
|
||||||
|
@ -645,7 +635,15 @@ pub fn sort_process_data(
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
ProcessSorting::Count => {
|
ProcessSorting::Count => {
|
||||||
// Nothing should happen here.
|
if proc_widget_state.is_grouped {
|
||||||
|
to_sort_vec.sort_by(|a, b| {
|
||||||
|
utils::gen_util::get_ordering(
|
||||||
|
a.group_pids.len(),
|
||||||
|
b.group_pids.len(),
|
||||||
|
proc_widget_state.process_sorting_reverse,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue