Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion crates/bashkit/src/builtins/rg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ impl RgOptions {
opts.show_filename = true;
} else if p.flag("--no-line-number") {
opts.line_numbers = false;
opts.line_numbers_explicit = false;
} else if p.flag("--line-number") {
opts.line_numbers = true;
opts.line_numbers_explicit = true;
Expand Down Expand Up @@ -1023,7 +1024,10 @@ impl RgOptions {
opts.line_numbers = true;
opts.line_numbers_explicit = true;
}
'N' => opts.line_numbers = false,
'N' => {
opts.line_numbers = false;
opts.line_numbers_explicit = false;
}
'c' => opts.set_count_only(),
'l' => opts.set_files_with_matches(),
'v' => opts.invert_match = true,
Expand Down Expand Up @@ -12602,6 +12606,37 @@ mod tests {
assert_eq!(result.stdout.trim(), "world");
}

#[tokio::test]
async fn test_rg_no_line_number_clears_explicit_state_short() {
let result = run_rg(
&["-n", "-N", "--column", "--no-column", "world", "/test.txt"],
None,
&[("/test.txt", b"hello\nworld\n")],
)
.await;
assert_eq!(result.exit_code, 0);
assert_eq!(result.stdout.trim(), "world");
}

#[tokio::test]
async fn test_rg_no_line_number_clears_explicit_state_long() {
let result = run_rg(
&[
"--line-number",
"--no-line-number",
"--column",
"--no-column",
"world",
"/test.txt",
],
None,
&[("/test.txt", b"hello\nworld\n")],
)
.await;
assert_eq!(result.exit_code, 0);
assert_eq!(result.stdout.trim(), "world");
}

#[tokio::test]
async fn test_rg_line_number_long_flag() {
// --line-number flag enables line numbers
Expand Down
Loading