1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-29 22:20:05 +08:00

update ignore case usage

This commit is contained in:
2019-08-03 10:55:30 +08:00
parent 3513ed810f
commit d3f920327a

View File

@@ -131,12 +131,11 @@ impl MatchLine {
} }
fn match_lines(tag: &str, content: &String, options: &Options) { fn match_lines(tag: &str, content: &String, options: &Options) {
let ignore_case = options.ignore_case;
let search_text = &options.search_text; let search_text = &options.search_text;
let lines = content.lines(); let lines = content.lines();
let mut match_lines_vec = vec![]; let mut match_lines_vec = vec![];
let mut l_no = 0usize; let mut l_no = 0usize;
let the_search_text = &match ignore_case { let the_search_text = &match options.ignore_case {
true => search_text.to_lowercase(), true => search_text.to_lowercase(),
false => search_text.to_string(), false => search_text.to_string(),
}; };
@@ -148,7 +147,7 @@ fn match_lines(tag: &str, content: &String, options: &Options) {
} }
continue; continue;
} }
let matches = match ignore_case { let matches = match options.ignore_case {
true => ln.to_lowercase().contains(the_search_text), true => ln.to_lowercase().contains(the_search_text),
false => ln.contains(the_search_text), false => ln.contains(the_search_text),
}; };
@@ -163,7 +162,7 @@ fn match_lines(tag: &str, content: &String, options: &Options) {
print_message(MessageType::OK, &format!("Find in {}:", tag)); print_message(MessageType::OK, &format!("Find in {}:", tag));
for i in 0..match_lines_vec.len() { for i in 0..match_lines_vec.len() {
print!("{}: ", match_lines_vec[i].line_number + 1); print!("{}: ", match_lines_vec[i].line_number + 1);
match ignore_case { match options.ignore_case {
true => println!("{}", match_lines_vec[i].line_string), true => println!("{}", match_lines_vec[i].line_string),
false => { false => {
let ss: Vec<&str> = match_lines_vec[i].line_string.split(search_text).collect(); let ss: Vec<&str> = match_lines_vec[i].line_string.split(search_text).collect();