Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cbandera
Copy link

@cbandera cbandera commented Jan 14, 2026

This PullRequest makes the search mode configurable between the existing pattern search mode and a new regex based search mode. The regex search mode can be enabled by setting the MCFLY_SEARCH_MODE environment variable to regex or by using the F4 key in the UI (see new entry in menu bar).

Screenshot 2026-01-14 213200

The regex syntax follows crate regex. Invalid regex patterns will simply return no results. Fuzzy search is not supported in regex mode.

closes #278
closes #467

This commit makes the search mode configurable between the existing pattern search mode and a new regex based search mode.
The regex search mode can be enabled by setting the `MCFLY_SEARCH_MODE` environment variable to `regex` or by using the `F4` key in the UI.

The regex syntax follows [crate regex](https://docs.rs/regex/latest/regex/#syntax).
Invalid regex patterns will simply return no results.
Fuzzy search is not supported in regex mode.
@cbandera
Copy link
Author

Some thoughts on the implementation:

  • I called the default/existing search mode Pattern Search, we could also name it Normal Search or anything else if you prefer
  • We could also migrate the Fuzzy Search to be one of the search modes that the user could cycle through, I didn't include this in this PR yet to keep it concise and because I didn't know how to keep backwards compatibility in this case...
  • In my setup there is a significant performance drop when switching to regex based search. I guess that is expected, but the fact that we need to perform the regex search twice (once in the SQL query and once for calculating the match indices) doesn't help of course. I don't know whether it's an option to not perform the search on SQL side at all and only filter on rust side once?

)
.unwrap_or_else(|err| panic!("McFly error: Successful create_scalar_function ({err})"));

db.create_scalar_function("regexp", 2, FunctionFlags::SQLITE_UTF8, |ctx| {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way this can be done natively in sqlite? Using a function call is likely why it's slow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find a way to do so while I was doing my reasearch on this.
But I am not very experienced with sqlite. Glad when I'm taught better.

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.

How to exclude some pattern when search cmd feature request: regex search

2 participants