comparison runtime/doc/eval.txt @ 23475:79fd5217b125 v8.2.2280

patch 8.2.2280: fuzzy matching doesn't give access to the scores Commit: https://github.com/vim/vim/commit/9d19e4f4ba55f8bef18d4991abdf740ff6472dba Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 2 18:31:32 2021 +0100 patch 8.2.2280: fuzzy matching doesn't give access to the scores Problem: Fuzzy matching doesn't give access to the scores. Solution: Return the scores with a third list. (Yegappan Lakshmanan, closes #7596)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Jan 2021 18:45:03 +0100
parents 15fa3923cc49
children 87671ccc6c6b
comparison
equal deleted inserted replaced
23474:e4906ec48336 23475:79fd5217b125
7469 \ {'matchseq': 1}) 7469 \ {'matchseq': 1})
7470 < results in ['two one']. 7470 < results in ['two one'].
7471 7471
7472 matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* 7472 matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
7473 Same as |matchfuzzy()|, but returns the list of matched 7473 Same as |matchfuzzy()|, but returns the list of matched
7474 strings and the list of character positions where characters 7474 strings, the list of character positions where characters
7475 in {str} matches. You can use |byteidx()|to convert a 7475 in {str} matches and a list of matching scores. You can
7476 character position to a byte position. 7476 use |byteidx()|to convert a character position to a byte
7477 7477 position.
7478 7478
7479 If {str} matches multiple times in a string, then only the 7479 If {str} matches multiple times in a string, then only the
7480 positions for the best match is returned. 7480 positions for the best match is returned.
7481 7481
7482 If there are no matching strings or there is an error, then a 7482 If there are no matching strings or there is an error, then a
7483 list with two empty list items is returned. 7483 list with three empty list items is returned.
7484 7484
7485 Example: > 7485 Example: >
7486 :echo matchfuzzypos(['testing'], 'tsg') 7486 :echo matchfuzzypos(['testing'], 'tsg')
7487 < results in [['testing'], [[0, 2, 6]]] > 7487 < results in [['testing'], [[0, 2, 6]], [99]] >
7488 :echo matchfuzzypos(['clay', 'lacy'], 'la') 7488 :echo matchfuzzypos(['clay', 'lacy'], 'la')
7489 < results in [['lacy', 'clay'], [[0, 1], [1, 2]]] > 7489 < results in [['lacy', 'clay'], [[0, 1], [1, 2]], [153, 133]] >
7490 :echo [{'text': 'hello', 'id' : 10}]->matchfuzzypos('ll', {'key' : 'text'}) 7490 :echo [{'text': 'hello', 'id' : 10}]->matchfuzzypos('ll', {'key' : 'text'})
7491 < results in [{'id': 10, 'text': 'hello'}] [[2, 3]] 7491 < results in [[{'id': 10, 'text': 'hello'}], [[2, 3]], [127]]
7492 7492
7493 matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* 7493 matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
7494 Same as |match()|, but return a |List|. The first item in the 7494 Same as |match()|, but return a |List|. The first item in the
7495 list is the matched string, same as what matchstr() would 7495 list is the matched string, same as what matchstr() would
7496 return. Following items are submatches, like "\1", "\2", etc. 7496 return. Following items are submatches, like "\1", "\2", etc.