Skip to content

Commit 8f66127

Browse files
midichefanjakefala
authored andcommitted
[cmdpalette-] make fuzzy match case-insensitive
lowercase and uppercase patterns were failing to match to uppercase strings.
1 parent f40ba4c commit 8f66127

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

visidata/fuzzymatch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,16 @@ def _format_match(s, positions):
367367

368368
@VisiData.api
369369
def fuzzymatch(vd, haystack:"list[dict[str, str]]", needles:"list[str]) -> list[CombinedMatch]"):
370-
'Return sorted list of matching dict values in haystack, augmenting the input dicts with _score:int and _positions:dict[k,set[int]] where k is each non-_ key in the haystack dict.'
371-
370+
'''Perform case-insensitive matching. Return sorted list of matching dict values in haystack, augmenting the input dicts with _score:int and _positions:dict[k,set[int]] where k is each non-_ key in the haystack dict.'''
371+
needles = [ p.lower() for p in needles]
372372
matches = []
373373
for h in haystack:
374374
match = {}
375375
formatted_hay = {}
376376
for k, v in h.items():
377377
if k[0] == '_': continue
378378
positions = set()
379+
v = v.lower()
379380
for p in needles:
380381
mr = _fuzzymatch(v, p)
381382
if mr.score > 0:

0 commit comments

Comments
 (0)