Explorar o código

Move `mark` function to private namespace.

Afshin Darian %!s(int64=8) %!d(string=hai) anos
pai
achega
ad4b5bded3
Modificáronse 1 ficheiros con 10 adicións e 8 borrados
  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.
    *