-
Notifications
You must be signed in to change notification settings - Fork 330
search: Restore implied 'AND' behavior in non-regex file match mode #3659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
mode. If multiple words are encountered, they will be treated as separate search terms and be matched separately, requiring all to 'hit' for a file to be included in results. Full wildcard matching will still work for each word. ref: linuxmint/mint22.3-beta#29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR restores the traditional "implied AND" behavior for file search in non-regex mode. Previously (before version 6.6), when users entered multiple words separated by spaces, the search would require all words to match. This functionality was lost when switching to GPatternSpec for glob matching, and this PR restores it.
Key changes:
- Simplified query editor logic to pass raw search strings to the search engine in non-regex mode
- Modified search engine to split search strings by whitespace and create multiple pattern specs
- Implemented AND logic where all word patterns must match for a file to be included in results
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/nemo-query-editor.c | Removed automatic asterisk wrapping in non-regex mode, delegating this responsibility to the search engine |
| libnemo-private/nemo-search-engine-advanced.c | Changed from single GPatternSpec to list of patterns, implementing word splitting and AND matching logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /* In (< 6.6), whitespace between words was treated as AND, and implied a filename | ||
| * must include *this* AND *that* AND *other*. To preserve this behavior, split | ||
| * the search text and wrap segments individually (*segment*) if no wildcard characters | ||
| * already included, and generate a GPatternSpec for each segment. */ |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version reference in the comment mentions "< 6.6", which appears to be comparing against a future or non-existent version. Please verify that this version number is accurate and represents a valid released or planned version.
| /* In (< 6.6), whitespace between words was treated as AND, and implied a filename | |
| * must include *this* AND *that* AND *other*. To preserve this behavior, split | |
| * the search text and wrap segments individually (*segment*) if no wildcard characters | |
| * already included, and generate a GPatternSpec for each segment. */ | |
| /* In earlier versions, whitespace between words was treated as AND, and implied a filename | |
| * must include *this* AND *that* AND *other*. To preserve this behavior, split | |
| * the search text and wrap segments individually (*segment*) if no wildcard characters | |
| * are included, and generate a GPatternSpec for each segment. */ |
| data->filename_glob_patterns = g_list_prepend (data->filename_glob_patterns, pattern); | ||
| } | ||
| } | ||
|
|
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user enters only spaces or a pattern where all words become empty strings after splitting, the filename_glob_patterns list could remain empty. When matching in visit_directory, the loop starting at line 1042 would not execute any iterations, leaving hit as TRUE, which means files would match even though no valid pattern exists. Consider adding validation to ensure at least one valid pattern exists, or handle the empty list case explicitly.
| /* If no valid (non-empty) pattern segments were found, ensure that | |
| * the filename_glob_patterns list is not empty. Using a sentinel | |
| * pattern that cannot match any regular filename ("/") prevents | |
| * whitespace-only or otherwise invalid patterns from matching all | |
| * files. */ | |
| if (data->filename_glob_patterns == NULL) { | |
| GPatternSpec *pattern = g_pattern_spec_new ("/"); | |
| data->filename_glob_patterns = g_list_prepend (data->filename_glob_patterns, pattern); | |
| } |
If multiple words are encountered, they will be treated as separate search terms and be matched separately, requiring all to 'hit' for a file to be included in results.
Full wildcard matching will still work for each word.
ref:
linuxmint/mint22.3-beta#29