bug: Fix sorting menu and sort shortcuts not syncing in gui (#417)

Fixes sorting menus and shortcuts not syncing correctly if the sorting window is open.
This commit is contained in:
Clement Tsang 2021-02-19 01:02:21 -05:00 committed by GitHub
parent e6230ef156
commit e6c9187928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 62 deletions

View File

@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing. - [#416](https://github.com/ClementTsang/bottom/pull/416): Fixes grouped vs ungrouped modes in the processes widget having inconsistent spacing.
- [#417](https://github.com/ClementTsang/bottom/pull/417): Fixes the sort menu and sort shortcuts not syncing up.
## [0.5.7] - 2021-01-30 ## [0.5.7] - 2021-01-30
## Bug Fixes ## Bug Fixes

View File

@ -700,8 +700,8 @@ impl App {
.widget_states .widget_states
.get_mut(&(self.current_widget.widget_id - 2)) .get_mut(&(self.current_widget.widget_id - 2))
{ {
self.proc_state.force_update = Some(self.current_widget.widget_id - 2);
proc_widget_state.update_sorting_with_columns(); proc_widget_state.update_sorting_with_columns();
self.proc_state.force_update = Some(self.current_widget.widget_id - 2);
self.toggle_sort(); self.toggle_sort();
} }
} }
@ -1473,25 +1473,15 @@ impl App {
} }
'c' => { 'c' => {
if let BottomWidgetType::Proc = self.current_widget.widget_type { if let BottomWidgetType::Proc = self.current_widget.widget_type {
// FIXME: There's a mismatch bug with this and all sorting types when using the keybind vs the sorting menu.
// If the sorting menu is open, it won't update when using this!
if let Some(proc_widget_state) = self if let Some(proc_widget_state) = self
.proc_state .proc_state
.get_mut_widget_state(self.current_widget.widget_id) .get_mut_widget_state(self.current_widget.widget_id)
{ {
match proc_widget_state.process_sorting_type { proc_widget_state
processes::ProcessSorting::CpuPercent => { .columns
proc_widget_state.is_process_sort_descending = .set_to_sorted_index_from_type(&processes::ProcessSorting::CpuPercent);
!proc_widget_state.is_process_sort_descending proc_widget_state.update_sorting_with_columns();
}
_ => {
proc_widget_state.process_sorting_type =
processes::ProcessSorting::CpuPercent;
proc_widget_state.is_process_sort_descending = true;
}
}
self.proc_state.force_update = Some(self.current_widget.widget_id); self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first(); self.skip_to_first();
} }
} }
@ -1502,25 +1492,17 @@ impl App {
.proc_state .proc_state
.get_mut_widget_state(self.current_widget.widget_id) .get_mut_widget_state(self.current_widget.widget_id)
{ {
match proc_widget_state.process_sorting_type { proc_widget_state.columns.set_to_sorted_index_from_type(
processes::ProcessSorting::MemPercent &(if proc_widget_state
| processes::ProcessSorting::Mem => { .columns
proc_widget_state.is_process_sort_descending = .is_enabled(&processes::ProcessSorting::MemPercent)
!proc_widget_state.is_process_sort_descending {
} processes::ProcessSorting::MemPercent
} else {
_ => { processes::ProcessSorting::Mem
proc_widget_state.process_sorting_type = if proc_widget_state }),
.columns );
.is_enabled(&processes::ProcessSorting::MemPercent) proc_widget_state.update_sorting_with_columns();
{
processes::ProcessSorting::MemPercent
} else {
processes::ProcessSorting::Mem
};
proc_widget_state.is_process_sort_descending = true;
}
}
self.proc_state.force_update = Some(self.current_widget.widget_id); self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first(); self.skip_to_first();
} }
@ -1534,17 +1516,10 @@ impl App {
{ {
// Skip if grouped // Skip if grouped
if !proc_widget_state.is_grouped { if !proc_widget_state.is_grouped {
match proc_widget_state.process_sorting_type { proc_widget_state
processes::ProcessSorting::Pid => { .columns
proc_widget_state.is_process_sort_descending = .set_to_sorted_index_from_type(&processes::ProcessSorting::Pid);
!proc_widget_state.is_process_sort_descending proc_widget_state.update_sorting_with_columns();
}
_ => {
proc_widget_state.process_sorting_type =
processes::ProcessSorting::Pid;
proc_widget_state.is_process_sort_descending = false;
}
}
self.proc_state.force_update = Some(self.current_widget.widget_id); self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first(); self.skip_to_first();
} }
@ -1585,22 +1560,14 @@ impl App {
.proc_state .proc_state
.get_mut_widget_state(self.current_widget.widget_id) .get_mut_widget_state(self.current_widget.widget_id)
{ {
match proc_widget_state.process_sorting_type { proc_widget_state.columns.set_to_sorted_index_from_type(
processes::ProcessSorting::ProcessName &(if proc_widget_state.is_using_command {
| processes::ProcessSorting::Command => { processes::ProcessSorting::Command
proc_widget_state.is_process_sort_descending = } else {
!proc_widget_state.is_process_sort_descending processes::ProcessSorting::ProcessName
} }),
_ => { );
proc_widget_state.process_sorting_type = proc_widget_state.update_sorting_with_columns();
if proc_widget_state.is_using_command {
processes::ProcessSorting::Command
} else {
processes::ProcessSorting::ProcessName
};
proc_widget_state.is_process_sort_descending = false;
}
}
self.proc_state.force_update = Some(self.current_widget.widget_id); self.proc_state.force_update = Some(self.current_widget.widget_id);
self.skip_to_first(); self.skip_to_first();
} }

View File

@ -507,7 +507,9 @@ impl ProcWidgetState {
// Also invert anything that uses alphabetical sorting by default. // Also invert anything that uses alphabetical sorting by default.
self.is_process_sort_descending = false; self.is_process_sort_descending = false;
} }
_ => {} _ => {
self.is_process_sort_descending = true;
}
} }
} }
} }