Skip to content

Conversation

@mtwebster
Copy link
Member

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

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
Copy link

Copilot AI left a 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.

Comment on lines +458 to +461
/* 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. */
Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
/* 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. */

Copilot uses AI. Check for mistakes.
data->filename_glob_patterns = g_list_prepend (data->filename_glob_patterns, pattern);
}
}

Copy link

Copilot AI Dec 24, 2025

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.

Suggested change
/* 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);
}

Copilot uses AI. Check for mistakes.
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.

1 participant