File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -833,9 +833,24 @@ const Hints = Module("hints", {
833
833
} ;
834
834
} //}}}
835
835
836
+ /**
837
+ * Get a hint matcher for hintmatching=fuzzy
838
+ *
839
+ * The user input can be anything. The matcher looks for occurances of
840
+ * the characters in the user input. If all occurances are found in the
841
+ * link, in order, the link is relevant.
842
+ *
843
+ * @param {string } hintString The string typed by the user.
844
+ * @returns {function(string):boolean } A function that takes the text
845
+ * of a hint and returns true if all characters of the input are
846
+ * found in the link.
847
+ */
836
848
function fuzzyMatcher ( hintString ) {
837
849
expression = '';
838
850
851
+ // Build a regex for fuzzy matching with the input.
852
+ //
853
+ // If the input is 'abc', the regex will be '[^a]*a[^b]*b[^c]c'.
839
854
for ( var i = 0 ; i < hintString . length ; i ++ ) {
840
855
var char = hintString [ i ] ;
841
856
expression += '[^' + char + ']*' + char ;
You can’t perform that action at this time.
0 commit comments