[Bf-blender-cvs] [f381c73a21d] master: Fix T95257: Filter files on "name" and "relpath"

Harley Acheson noreply at git.blender.org
Sat Mar 19 17:24:25 CET 2022


Commit: f381c73a21d3095e64657fab4fe02aa4ac320a14
Author: Harley Acheson
Date:   Sat Mar 19 09:23:05 2022 -0700
Branches: master
https://developer.blender.org/rBf381c73a21d3095e64657fab4fe02aa4ac320a14

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

===================================================================

M	source/blender/editors/space_file/filelist.c

===================================================================

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,



More information about the Bf-blender-cvs mailing list