Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmdpalette-] make fuzzy match case-insensitive #2658

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions visidata/fuzzymatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,16 @@ def _format_match(s, positions):

@VisiData.api
def fuzzymatch(vd, haystack:"list[dict[str, str]]", needles:"list[str]) -> list[CombinedMatch]"):
'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.'

'''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.'''
needles = [ p.lower() for p in needles]
matches = []
for h in haystack:
match = {}
formatted_hay = {}
for k, v in h.items():
if k[0] == '_': continue
positions = set()
v = v.lower()
for p in needles:
mr = _fuzzymatch(v, p)
if mr.score > 0:
Expand Down
Loading