Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2022-03-19 19:23:05 +0300
committerHarley Acheson <harley.acheson@gmail.com>2022-03-19 19:23:05 +0300
commitf381c73a21d3095e64657fab4fe02aa4ac320a14 (patch)
treecbfb1f91bb92ba51cbd7484f3f4fc2faa5ad8765
parent82c852f38732a005a1da72f4fb7fb402ecd71ec0 (diff)
Fix T95257: Filter files on "name" and "relpath"
When filtering File Browser items by name, use entry's "name" field as well as the "relpath" field since they can vary. See D13940 for details. Differential Revision: https://developer.blender.org/D13940 Reviewed by Bastien Montagne
-rw-r--r--source/blender/editors/space_file/filelist.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 363e19a8905..180e30a11d4 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -851,6 +851,20 @@ static bool is_filtered_file_relpath(const FileListInternEntry *file, const File
return fnmatch(filter->filter_search, file->relpath, FNM_CASEFOLD) == 0;
}
+/**
+ * Apply the filter string as matching pattern on file name.
+ * \return true when the file should be in the result set, false if it should be filtered out.
+ */
+static bool is_filtered_file_name(const FileListInternEntry *file, const FileListFilter *filter)
+{
+ if (filter->filter_search[0] == '\0') {
+ return true;
+ }
+
+ /* If there's a filter string, apply it as filter even if FLF_DO_FILTER is not set. */
+ return fnmatch(filter->filter_search, file->name, FNM_CASEFOLD) == 0;
+}
+
/** \return true when the file should be in the result set, false if it should be filtered out. */
static bool is_filtered_file_type(const FileListInternEntry *file, const FileListFilter *filter)
{
@@ -890,7 +904,8 @@ static bool is_filtered_file(FileListInternEntry *file,
const char *UNUSED(root),
FileListFilter *filter)
{
- return is_filtered_file_type(file, filter) && is_filtered_file_relpath(file, filter);
+ return is_filtered_file_type(file, filter) &&
+ (is_filtered_file_relpath(file, filter) || is_filtered_file_name(file, filter));
}
static bool is_filtered_id_file_type(const FileListInternEntry *file,