bug: Fix sizing in search and broken tab logic

This commit is contained in:
Clement Tsang 2020-04-07 22:38:22 -04:00 committed by GitHub
parent b32c984843
commit 7d9ad1ee78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View File

@ -720,12 +720,12 @@ impl App {
let is_in_search_widget = self.is_in_search_widget();
if !self.is_in_dialog() {
if is_in_search_widget {
if let Some(proc_widget_state) = self
.proc_state
.widget_states
.get_mut(&(self.current_widget.widget_id - 1))
{
if is_in_search_widget {
if !proc_widget_state.is_grouped {
if proc_widget_state.process_search_state.is_searching_with_pid {
self.search_with_name();
@ -733,7 +733,12 @@ impl App {
self.search_with_pid();
}
}
} else {
}
} else if let Some(proc_widget_state) = self
.proc_state
.widget_states
.get_mut(&self.current_widget.widget_id)
{
// Toggles process widget grouping state
proc_widget_state.is_grouped = !(proc_widget_state.is_grouped);
if proc_widget_state.is_grouped {
@ -742,7 +747,6 @@ impl App {
}
}
}
}
/// I don't like this, but removing it causes a bunch of breakage.
/// Use ``proc_widget_state.is_grouped`` if possible!

View File

@ -1,4 +1,4 @@
use std::cmp::{max, min};
use std::cmp::max;
use crate::{
app::{self, App, ProcWidgetState},
@ -319,12 +319,14 @@ impl ProcessTableWidget for Painter {
let is_on_widget = widget_id == app_state.current_widget.widget_id;
let num_columns = draw_loc.width as usize;
let small_mode = chosen_text.len() != min(num_columns / 2, chosen_text.len());
let small_mode = num_columns < 70;
let search_title: &str = if !small_mode {
chosen_text
} else if chosen_text.is_empty() {
""
} else if proc_widget_state.process_search_state.is_searching_with_pid {
} else if proc_widget_state.process_search_state.is_searching_with_pid
&& !proc_widget_state.is_grouped
{
"p> "
} else {
"n> "