浏览代码

Merge pull request #9446 from jtpio/fuzzy-lowercase

Support for lowercase search queries in the file browser
Steven Silvester 4 年之前
父节点
当前提交
93aee5ea26
共有 1 个文件被更改,包括 5 次插入11 次删除
  1. 5 11
      packages/filebrowser/src/search.tsx

+ 5 - 11
packages/filebrowser/src/search.tsx

@@ -36,19 +36,12 @@ interface IScore {
    * The indices of the text matches.
    */
   indices: number[] | null;
-
-  /**
-   * The command item associated with the match.
-   */
-  item: Contents.IModel;
 }
 
 /**
  * Perform a fuzzy search on a single item.
  */
-function fuzzySearch(item: Contents.IModel, query: string): IScore | null {
-  let source = `${item.name}`;
-
+function fuzzySearch(source: string, query: string): IScore | null {
   // Set up the match score and indices array.
   let score = Infinity;
   let indices: number[] | null = null;
@@ -91,8 +84,7 @@ function fuzzySearch(item: Contents.IModel, query: string): IScore | null {
   // Handle a split match.
   return {
     score,
-    indices,
-    item
+    indices
   };
 }
 
@@ -116,7 +108,9 @@ const FilterBox = (props: IFilterBoxProps) => {
     props.listing.model.setFilter((item: Contents.IModel) => {
       if (props.useFuzzyFilter) {
         // Run the fuzzy search for the item and query.
-        let score = fuzzySearch(item, target.value);
+        const name = item.name.toLowerCase();
+        const query = target.value.toLowerCase();
+        let score = fuzzySearch(name, query);
         // Ignore the item if it is not a match.
         if (!score) {
           item.indices = [];