Browse Source

Move `mark` function to private namespace.

Afshin Darian 8 năm trước cách đây
mục cha
commit
ad4b5bded3
1 tập tin đã thay đổi với 10 bổ sung8 xóa
  1. 10 8
      src/completer/model.ts

+ 10 - 8
src/completer/model.ts

@@ -264,10 +264,11 @@ class CompleterModel implements CompleterWidget.IModel {
     for (let option of options) {
       let match = StringExt.matchSumOfSquares(option, query);
       if (match) {
+        let marked = StringExt.highlight(option, match.indices, Private.mark);
         results.push({
           raw: option,
           score: match.score,
-          text: StringExt.highlight(option, match.indices, this._mark).join('')
+          text: marked.join('')
         });
       }
     }
@@ -276,13 +277,6 @@ class CompleterModel implements CompleterWidget.IModel {
     );
   }
 
-  /**
-   * Mark a highlighted chunk of text.
-   */
-  private _mark(value: string): string {
-    return `<mark>${value}</mark>`;
-  }
-
   /**
    * Reset the state of the model.
    */
@@ -333,6 +327,14 @@ namespace Private {
     text: string;
   }
 
+  /**
+   * Mark a highlighted chunk of text.
+   */
+  export
+  function mark(value: string): string {
+    return `<mark>${value}</mark>`;
+  }
+
   /**
    * A sort comparison function for item match scores.
    *