summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--crates/core/flags/hiargs.rs14
2 files changed, 15 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 795d26b9..05cfc610 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,8 @@ Feature enhancements:
When `extra-verbose` mode is enabled in zsh, show extra file type info.
* [FEATURE #2409](https://github.com/BurntSushi/ripgrep/pull/2409):
Added installation instructions for `winget`.
+* [FEATURE #2524](https://github.com/BurntSushi/ripgrep/issues/2524):
+ The `--debug` flag now indicates whether stdin or `./` is being searched.
* [FEATURE #2643](https://github.com/BurntSushi/ripgrep/issues/2643):
Make `-d` a short flag for `--max-depth`.
diff --git a/crates/core/flags/hiargs.rs b/crates/core/flags/hiargs.rs
index b4e0c096..555c8bd6 100644
--- a/crates/core/flags/hiargs.rs
+++ b/crates/core/flags/hiargs.rs
@@ -1080,12 +1080,24 @@ impl Paths {
// mode, but there really is no good way to mitigate it. It's just a
// consequence of letting the user type 'rg foo' and "guessing" that
// they meant to search the CWD.
- let use_cwd = !grep::cli::is_readable_stdin()
+ let is_readable_stdin = grep::cli::is_readable_stdin();
+ let use_cwd = !is_readable_stdin
|| state.stdin_consumed
|| !matches!(low.mode, Mode::Search(_));
+ log::debug!(
+ "using heuristics to determine whether to read from \
+ stdin or search ./ (\
+ is_readable_stdin={is_readable_stdin}, \
+ stdin_consumed={stdin_consumed}, \
+ mode={mode:?})",
+ stdin_consumed = state.stdin_consumed,
+ mode = low.mode,
+ );
let (path, is_one_file) = if use_cwd {
+ log::debug!("heuristic chose to search ./");
(PathBuf::from("./"), false)
} else {
+ log::debug!("heuristic chose to search stdin");
(PathBuf::from("-"), true)
};
Ok(Paths { paths: vec![path], has_implicit_path: true, is_one_file })