@@ -4,6 +4,7 @@ use crate::columns::*;
44use crate :: config:: * ;
55use crate :: opt:: { ArgColorMode , ArgPagerMode } ;
66use crate :: process:: collect_proc;
7+ use crate :: search_regex:: SearchRegex ;
78use crate :: style:: { apply_color, apply_style, color_to_column_style} ;
89use crate :: term_info:: TermInfo ;
910use crate :: util:: {
@@ -13,7 +14,6 @@ use crate::util::{
1314use anyhow:: { Error , bail} ;
1415#[ cfg( not( target_os = "windows" ) ) ]
1516use pager:: Pager ;
16- use regex:: RegexBuilder ;
1717use std:: collections:: HashMap ;
1818use std:: time:: Duration ;
1919
@@ -263,9 +263,7 @@ impl View {
263263 ConfigSearchCase :: Insensitive => true ,
264264 ConfigSearchCase :: Sensitive => false ,
265265 } ;
266- let regex = RegexBuilder :: new ( pattern)
267- . case_insensitive ( ignore_case)
268- . build ( ) ?;
266+ let regex = SearchRegex :: new ( pattern, ignore_case) ?;
269267 Some ( regex)
270268 } else {
271269 None
@@ -316,7 +314,7 @@ impl View {
316314 } else if opt. keyword . is_empty ( ) {
317315 true
318316 } else if let Some ( regex) = & regex {
319- View :: search_regex ( * pid, cols_searchable. as_slice ( ) , regex)
317+ View :: search_regex ( * pid, cols_searchable. as_slice ( ) , regex) ?
320318 } else {
321319 View :: search (
322320 * pid,
@@ -714,8 +712,13 @@ impl View {
714712 }
715713 }
716714
717- fn search_regex ( pid : i32 , cols : & [ & dyn Column ] , regex : & regex:: Regex ) -> bool {
718- cols. iter ( ) . any ( |c| regex. is_match ( & c. display_json ( pid) ) )
715+ fn search_regex ( pid : i32 , cols : & [ & dyn Column ] , regex : & SearchRegex ) -> Result < bool , Error > {
716+ for c in cols {
717+ if regex. is_match ( & c. display_json ( pid) ) ? {
718+ return Ok ( true ) ;
719+ }
720+ }
721+ Ok ( false )
719722 }
720723
721724 #[ cfg( not( any( target_os = "windows" , any( target_os = "linux" , target_os = "android" ) ) ) ) ]
0 commit comments