Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Nov 14, 2023
1 parent 9919e32 commit afe9f36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/core/flags/midargs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,21 @@ impl MidArgs {
Ok(PatternMatcher::RustRegex(m))
}

/// Returns true if some non-zero number of matches is believed to be
/// possible.
///
/// When this returns false, it is impossible for ripgrep to ever report
/// a match.
pub(crate) fn matches_possible(&self) -> bool {
if self.patterns.patterns.is_empty() {
return false;
}
if self.max_count == Some(0) {
return false;
}
true
}

pub(crate) fn overrides(
&self,
) -> anyhow::Result<ignore::overrides::Override> {
Expand Down
1 change: 1 addition & 0 deletions crates/core/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ fn run(result: flags::ParseResult<Args>) -> anyhow::Result<ExitCode> {
ParseResult::Ok(args) => args,
};
let matched = match args.mode {
Mode::Search(_) if !args.matches_possible() => false,
Mode::Search(mode) if args.threads == 1 => search(&args, mode)?,
Mode::Search(mode) => search_parallel(&args, mode)?,
Mode::Files if args.threads == 1 => files(&args)?,
Expand Down

0 comments on commit afe9f36

Please sign in to comment.