Skip to content

Add regex filtering support (Fixes #554)#882

Merged
dalance merged 2 commits intodalance:masterfrom
sabbellasri:feature/regex-filter
Mar 22, 2026
Merged

Add regex filtering support (Fixes #554)#882
dalance merged 2 commits intodalance:masterfrom
sabbellasri:feature/regex-filter

Conversation

@sabbellasri
Copy link
Contributor

Added --text, --regex, --smart
Regex filtering path in View::filter
Interactive regex edit in watch mode (/, Enter, Esc)
regex moved to top-level dependencies for cross-platform build compatibility.

@sabbellasri sabbellasri force-pushed the feature/regex-filter branch from d0942a3 to 172e252 Compare March 12, 2026 17:50
@sabbellasri
Copy link
Contributor Author

Hi @dalance Following are the changes

Added new CLI search mode flags in opt.rs: --text, --regex, and --smart (mutually exclusive).

Kept existing text/numeric search logic unchanged, and added a separate regex path in view.rs so regex is only used when regex mode is active.

Added smart regex detection in util.rs (has_regex_syntax) to auto-switch behavior in --smart mode when regex-like symbols are present.

Added argument validation in main.rs:

--regex accepts only one pattern argument.
--smart also enforces single-pattern usage when regex syntax is detected.
Added interactive regex editing in watch mode in watcher.rs: press / to edit filter, Enter to apply, Esc to cancel, backspace support, and regex error display in header.

Updated dependency placement in Cargo.toml: moved regex to top-level [dependencies] so builds work on macOS/Linux/Windows (not only Linux/Android).

The CI checks appear to be waiting for workflow approval.
Could a maintainer please approve the workflow so the builds can run?

Thank you!

@sabbellasri sabbellasri force-pushed the feature/regex-filter branch from 172e252 to 2b317b7 Compare March 22, 2026 10:54
@sabbellasri
Copy link
Contributor Author

Hi @dalance, rebased on the latest upstream/master and pushed the updated branch. CI is green now, and the earlier FreeBSD failure appears to have been transient; the 3rd rerun passed. Ready for re-review.

@dalance
Copy link
Owner

dalance commented Mar 22, 2026

Thank you for your contribution!
This PR looks good.
I have a comment about magic numbers related with ASCII code (e.g. 10, 13, ...).
It may be better that there are some comments about them.

@sabbellasri
Copy link
Contributor Author

Hi @dalance, I replaced the raw ASCII key codes in watch mode with named constants for Enter, Esc, and Backspace/Delete in watcher.rs. Behavior is unchanged, but the code should be clearer now. If this looks good, I can merge this update into the PR.

@dalance
Copy link
Owner

dalance commented Mar 22, 2026

I can't see your file? but it probably no problem. Please update the PR.

@dalance dalance merged commit 9cf0591 into dalance:master Mar 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants