From b8a67bf5b913880c885504d4d9372df716b555c2 Mon Sep 17 00:00:00 2001 From: Mykhailo Chalyi Date: Sun, 24 May 2026 21:27:04 -0500 Subject: [PATCH] fix(rg): count unrestricted flags independently --- crates/bashkit/src/builtins/rg/mod.rs | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/crates/bashkit/src/builtins/rg/mod.rs b/crates/bashkit/src/builtins/rg/mod.rs index f4ff7fd7..c0583eca 100644 --- a/crates/bashkit/src/builtins/rg/mod.rs +++ b/crates/bashkit/src/builtins/rg/mod.rs @@ -96,6 +96,7 @@ struct RgOptions { ignore_file_case_insensitive: bool, unicode: bool, messages: bool, + unrestricted_level: u8, context_separator: String, no_context_separator: bool, field_match_separator: String, @@ -159,12 +160,11 @@ struct RgTypeGlob { impl RgOptions { fn apply_unrestricted(&mut self) { - if !self.no_ignore { - self.no_ignore = true; - } else if !self.hidden { - self.hidden = true; - } else { - self.binary = true; + self.unrestricted_level = self.unrestricted_level.saturating_add(1); + match self.unrestricted_level { + 1 => self.no_ignore = true, + 2 => self.hidden = true, + _ => self.binary = true, } } @@ -235,6 +235,7 @@ impl RgOptions { ignore_file_case_insensitive: false, unicode: true, messages: true, + unrestricted_level: 0, context_separator: "--".to_string(), no_context_separator: false, field_match_separator: ":".to_string(), @@ -5577,6 +5578,22 @@ mod tests { cwd: "/", output: RgDiffOutput::UnorderedLines, }, + RgDiffCase { + name: "explicit no-ignore does not advance unrestricted level", + args: &["--no-ignore", "-u", "needle", "proj"], + stdin: None, + files: DIFF_UNRESTRICTED_FILES, + cwd: "/", + output: RgDiffOutput::UnorderedLines, + }, + RgDiffCase { + name: "explicit hidden does not advance unrestricted level", + args: &["--hidden", "-uu", "needle", "proj"], + stdin: None, + files: DIFF_UNRESTRICTED_FILES, + cwd: "/", + output: RgDiffOutput::UnorderedLines, + }, RgDiffCase { name: "long unrestricted is repeatable", args: &["--unrestricted", "--unrestricted", "needle", "proj"],