Skip to content

fix(rg): clear explicit line-number state on negation#1750

Merged
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-line-number-negation-handling
May 25, 2026
Merged

fix(rg): clear explicit line-number state on negation#1750
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-line-number-negation-handling

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 25, 2026

Motivation

  • Fix correctness bug in rg option parsing where an earlier explicit --line-number/-n remained sticky via line_numbers_explicit, causing -n -N --column --no-column to incorrectly keep line numbers.
  • Ensure behavior matches real rg semantics where a negation (--no-line-number/-N) clears the explicit request state.

Description

  • Clear opts.line_numbers_explicit when parsing --no-line-number in the long-flag branch of the parser (crates/bashkit/src/builtins/rg/mod.rs).
  • Clear opts.line_numbers_explicit when parsing short -N in the combined-short-flag handling in the same file.
  • Add two regression tests validating the sequences -n -N --column --no-column and --line-number --no-line-number --column --no-column to ensure final output omits line-number prefixes.

Testing

  • Ran the focused test invocation cargo test -p bashkit test_rg_no_line_number_clears_explicit_state -- --nocapture and the two new tests passed.
  • Ran the crate test suite; unit tests completed with the new tests passing and no failures observed in the executed test runs.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 25, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit c9cb190 Commit Preview URL May 25 2026, 02:37 AM

Earlier explicit --line-number / -n left line_numbers_explicit sticky
through -N / --no-line-number negations, so '-n -N --column --no-column'
incorrectly kept line numbers in output. Real rg clears the explicit
request when the user negates it.

Clear opts.line_numbers_explicit on --no-line-number and on short -N
in combined-flag handling. Add regression tests for both short and
long forms.

Rebased on current main; original PR #1750 by chaliy.
@chaliy chaliy force-pushed the 2026-05-25-fix-rg-line-number-negation-handling branch from 83ca841 to 320e495 Compare May 25, 2026 15:19
@chaliy chaliy merged commit a224d5a into main May 25, 2026
33 checks passed
@chaliy chaliy deleted the 2026-05-25-fix-rg-line-number-negation-handling branch May 25, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant