1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-28 05:30:04 +08:00

add --filter-line-content

This commit is contained in:
2019-08-04 23:59:01 +08:00
parent 209963ebb2
commit 2ebcf56b30
2 changed files with 10 additions and 1 deletions

View File

@@ -120,7 +120,13 @@ fn match_lines(tag: &str, content: &String, options: &Options) -> bool {
true => ln.to_lowercase().contains(the_search_text),
false => ln.contains(the_search_text),
};
if matches {
let mut matches_line_content = true;
if options.filter_line_content.len() > 0 {
if ! ln.contains(options.filter_line_content.as_str()) {
matches_line_content = false;
}
}
if matches && matches_line_content {
match_lines_vec.push(MatchLine::new(l_no, ln.to_string()));
}
l_no += 1;