Skip to content

Commit

Permalink
bug: fix searching by command being broken (#204)
Browse files Browse the repository at this point in the history
Fixes searching by command name being broken.
  • Loading branch information
ClementTsang committed Aug 27, 2020
1 parent 83e3437 commit 2425779
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ impl App {
}

pub fn is_in_search_widget(&self) -> bool {
match self.current_widget.widget_type {
BottomWidgetType::ProcSearch => true,
_ => false,
}
matches!(
self.current_widget.widget_type,
BottomWidgetType::ProcSearch
)
}

fn reset_multi_tap_keys(&mut self) {
Expand Down
10 changes: 2 additions & 8 deletions src/app/layout_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,18 +887,12 @@ pub enum BottomWidgetType {
impl BottomWidgetType {
pub fn is_widget_table(&self) -> bool {
use BottomWidgetType::*;
match self {
Disk | Proc | ProcSort | Temp | CpuLegend => true,
_ => false,
}
matches!(self, Disk | Proc | ProcSort | Temp | CpuLegend)
}

pub fn is_widget_graph(&self) -> bool {
use BottomWidgetType::*;
match self {
Cpu | Net | Mem => true,
_ => false,
}
matches!(self, Cpu | Net | Mem)
}

pub fn get_pretty_name(&self) -> &str {
Expand Down
6 changes: 5 additions & 1 deletion src/app/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,11 @@ impl Prefix {
} else if let Some((prefix_type, query_content)) = &self.regex_prefix {
if let StringQuery::Regex(r) = query_content {
match prefix_type {
PrefixType::Name => r.is_match(process.name.as_str()),
PrefixType::Name => r.is_match(if is_using_command {
process.command.as_str()
} else {
process.name.as_str()
}),
PrefixType::Pid => r.is_match(process.pid.to_string().as_str()),
PrefixType::State => r.is_match(process.process_state.as_str()),
_ => true,
Expand Down
5 changes: 2 additions & 3 deletions src/canvas/drawing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ pub fn get_variable_intrinsic_widths(
let mut remaining_width = (total_width - (num_widths as u16 - 1)) as i32; // Required for spaces...
let desired_widths = desired_widths_ratio
.iter()
.map(|&desired_width_ratio| (desired_width_ratio * total_width as f64) as i32)
.collect::<Vec<_>>();
.map(|&desired_width_ratio| (desired_width_ratio * total_width as f64) as i32);

for (desired_width, resulting_width, width_threshold) in izip!(
desired_widths.into_iter(),
desired_widths,
resulting_widths.iter_mut(),
width_thresholds
) {
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,16 @@ pub fn handle_force_redraws(app: &mut App) {
}
}

#[allow(clippy::needless_collect)]
pub fn update_all_process_lists(app: &mut App) {
let widget_ids = app
.proc_state
.widget_states
.keys()
.cloned()
.collect::<Vec<_>>();

if !app.is_frozen {
let widget_ids = app
.proc_state
.widget_states
.keys()
.cloned()
.collect::<Vec<_>>();

widget_ids.into_iter().for_each(|widget_id| {
update_final_process_list(app, widget_id);
});
Expand Down

0 comments on commit 2425779

Please sign in to comment.