From 794d6c434e16d15add4dd7dfe8d8dda665af4f24 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 2 Aug 2026 15:27:34 -0700 Subject: [PATCH] fix(search): restore zero-match probes on the rg engine after auto-multiline early-return Integration regression between two merged PRs: #77102's rg-path early return (added to skip the grep-era line-oriented warning) also skipped the #77011 zero-match steering probes (case-insensitive, hidden-file, literal-vs-regex), silencing them on the primary engine. Caught by #77001's rebased CI run (its branch carried both features together for the first time). _search_content now runs the zero-match probe block for BOTH engines and only exempts the rg path from the legacy line-oriented \n warning (rg auto-enables --multiline; the grep fallback keeps the explanation). --- tools/file_operations.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/file_operations.py b/tools/file_operations.py index c3e4ef112dbbe..f6a2deacaba8c 100644 --- a/tools/file_operations.py +++ b/tools/file_operations.py @@ -2475,12 +2475,11 @@ class ShellFileOperations(FileOperations): limit: int, offset: int, output_mode: str, context: int) -> SearchResult: """Search for content inside files (grep-like).""" # Try ripgrep first (fast), fallback to grep (slower but works) + used_rg = False if self._has_command('rg'): + used_rg = True result = self._search_with_rg(pattern, path, file_glob, limit, offset, output_mode, context) - # rg auto-enables --multiline for \n patterns, so the line- - # oriented warning below no longer applies to this engine. - return result elif self._has_command('grep'): result = self._search_with_grep(pattern, path, file_glob, limit, offset, output_mode, context) @@ -2492,8 +2491,9 @@ class ShellFileOperations(FileOperations): ) # Zero-match steering: a 0-match result with no guidance is a dead - # turn. Probe cheaply for near-misses (wrong casing, unescaped regex - # metacharacters) and attach the finding as a warning. + # turn. Probe cheaply for near-misses (wrong casing, hidden-only + # matches, unescaped regex metacharacters) and attach the finding + # as a warning. Runs for BOTH engines. if (not result.error and result.total_count == 0 and not result.matches and not result.files and not result.counts): try: @@ -2503,6 +2503,10 @@ class ShellFileOperations(FileOperations): if hint: result.warning = hint if not result.warning else f"{result.warning} {hint}" + # rg auto-enables --multiline for \n patterns, so the line-oriented + # explanation only applies to the grep fallback engine. + if used_rg: + return result return _maybe_warn_line_oriented_newline_pattern(result, pattern) def _search_with_rg(self, pattern: str, path: str, file_glob: Optional[str],