diff --git a/src/ansi/mod.rs b/src/ansi/mod.rs index fe27bbe67..a634b6758 100644 --- a/src/ansi/mod.rs +++ b/src/ansi/mod.rs @@ -168,7 +168,7 @@ pub fn explain_ansi(line: &str, colorful: bool) -> String { if colorful { format!("({}){}", style.to_painted_string(), style.paint(s)) } else { - format!("({}){}", style.to_string(), s) + format!("({}){}", style, s) } }) .collect() diff --git a/src/handlers/blame.rs b/src/handlers/blame.rs index b3d628a66..010948539 100644 --- a/src/handlers/blame.rs +++ b/src/handlers/blame.rs @@ -185,9 +185,9 @@ lazy_static! { ( \^?[0-9a-f]{4,40} # commit hash (^ is 'boundary commit' marker) ) -(?: .+)? # optional file name (unused; present if file has been renamed; TODO: inefficient?) +(?: [^(]+)? # optional file name (unused; present if file has been renamed; TODO: inefficient?) [\ ] -\( # open ( +\( # open ( which the previous file name may not contain in case a name does (which is more likely) ( [^\ ].*[^\ ] # author name ) @@ -297,6 +297,14 @@ mod tests { } } + #[test] + fn test_blame_line_with_parens_in_name() { + let line = + "61f180c8 (Kangwook Lee (이강욱) 2021-06-09 23:33:59 +0900 130) let mut output_type ="; + let caps = BLAME_LINE_REGEX.captures(line).unwrap(); + assert_eq!(caps.get(2).unwrap().as_str(), "Kangwook Lee (이강욱)"); + } + #[test] fn test_color_assignment() { let mut writer = Cursor::new(vec![0; 512]); diff --git a/src/utils/process.rs b/src/utils/process.rs index f111e9d43..224eab876 100644 --- a/src/utils/process.rs +++ b/src/utils/process.rs @@ -481,7 +481,7 @@ where */ let pid_range = my_pid.saturating_sub(10)..my_pid.saturating_add(20); - for p in pid_range.clone() { + for p in pid_range { // Processes which were not refreshed do not exist for sysinfo, so by selectively // letting it know about processes the `find_sibling..` function will only // consider these.