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).
This commit is contained in:
Teknium 2026-08-02 15:27:34 -07:00
parent 1c39f1c9f9
commit 794d6c434e
1 changed files with 9 additions and 5 deletions

View File

@ -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],