@@ -2641,7 +2641,10 @@ matcharg({nr}) List arguments of |:match|
26412641matchdelete({id} [, {win}]) Number delete match identified by {id}
26422642matchend({expr}, {pat} [, {start} [, {count}]])
26432643 Number position where {pat} ends in {expr}
2644- matchfuzzy({list}, {str}) List fuzzy match {str} in {list}
2644+ matchfuzzy({list}, {str} [, {dict}])
2645+ List fuzzy match {str} in {list}
2646+ matchfuzzypos({list}, {str} [, {dict}])
2647+ List fuzzy match {str} in {list}
26452648matchlist({expr}, {pat} [, {start} [, {count}]])
26462649 List match and submatches of {pat} in {expr}
26472650matchstr({expr}, {pat} [, {start} [, {count}]])
@@ -7311,12 +7314,25 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
73117314 GetText()->matchend('word')
73127315
73137316
7314- matchfuzzy({list}, {str}) *matchfuzzy()*
7315- Returns a list with all the strings in {list} that fuzzy
7316- match {str}. The strings in the returned list are sorted
7317- based on the matching score. {str} is treated as a literal
7318- string and regular expression matching is NOT supported.
7319- The maximum supported {str} length is 256.
7317+ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
7318+ If {list} is a list of strings, then returns a list with all
7319+ the strings in {list} that fuzzy match {str}. The strings in
7320+ the returned list are sorted based on the matching score.
7321+
7322+ If {list} is a list of dictionaries, then the optional {dict}
7323+ argument supports the following items:
7324+ key key of the item which is fuzzy matched against
7325+ {str}. The value of this item should be a
7326+ string.
7327+ text_cb |Funcref| that will be called for every item
7328+ in {list} to get the text for fuzzy matching.
7329+ This should accept a dictionary item as the
7330+ argument and return the text for that item to
7331+ use for fuzzy matching.
7332+
7333+ {str} is treated as a literal string and regular expression
7334+ matching is NOT supported. The maximum supported {str} length
7335+ is 256.
73207336
73217337 If there are no matching strings or there is an error, then an
73227338 empty list is returned. If length of {str} is greater than
@@ -7327,11 +7343,36 @@ matchfuzzy({list}, {str}) *matchfuzzy()*
73277343< results in ["clay"]. >
73287344 :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl")
73297345< results in a list of buffer names fuzzy matching "ndl". >
7346+ :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'})
7347+ < results in a list of buffer information dicts with buffer
7348+ names fuzzy matching "ndl". >
7349+ :echo getbufinfo()->matchfuzzy("spl",
7350+ \ {'text_cb' : {v -> v.name}})
7351+ < results in a list of buffer information dicts with buffer
7352+ names fuzzy matching "spl". >
73307353 :echo v:oldfiles->matchfuzzy("test")
73317354< results in a list of file names fuzzy matching "test". >
73327355 :let l = readfile("buffer.c")->matchfuzzy("str")
73337356< results in a list of lines in "buffer.c" fuzzy matching "str".
73347357
7358+ matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
7359+ Same as |matchfuzzy()|, but returns the list of matched
7360+ strings and the list of character positions where characters
7361+ in {str} matches.
7362+
7363+ If {str} matches multiple times in a string, then only the
7364+ positions for the best match is returned.
7365+
7366+ If there are no matching strings or there is an error, then a
7367+ list with two empty list items is returned.
7368+
7369+ Example: >
7370+ :echo matchfuzzypos(['testing'], 'tsg')
7371+ < results in [['testing'], [[0, 2, 6]]] >
7372+ :echo matchfuzzypos(['clay', 'lacy'], 'la')
7373+ < results in [['lacy', 'clay'], [[0, 1], [1, 2]]] >
7374+ :echo [{'text': 'hello', 'id' : 10}]->matchfuzzypos('ll', {'key' : 'text'})
7375+ < results in [{'id': 10, 'text': 'hello'}] [[2, 3]]
73357376
73367377matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
73377378 Same as |match()|, but return a |List|. The first item in the
0 commit comments