1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-10-06 10:17:15 +03:00

Fix auto-completion breaking for table names with caps

This commit is contained in:
Anthony Lai 2016-03-22 23:03:06 -07:00
parent 289d960114
commit f1ff7158e0
2 changed files with 14 additions and 1 deletions

View File

@ -223,7 +223,7 @@ class PGCompleter(Completer):
pat = re.compile('(%s)' % regex) pat = re.compile('(%s)' % regex)
def _match(item): def _match(item):
r = pat.search(self.unescape_name(item)) r = pat.search(self.unescape_name(item.lower()))
if r: if r:
return -len(r.group()), -r.start() return -len(r.group()), -r.start()
else: else:

View File

@ -74,3 +74,16 @@ def test_should_break_ties_using_lexical_order(completer, collection):
matches = completer.find_matches(text, collection) matches = completer.find_matches(text, collection)
assert matches[1].priority > matches[0].priority assert matches[1].priority > matches[0].priority
def test_matching_should_be_case_insensitive(completer):
"""Fuzzy matching should keep matches even if letter casing doesn't match.
This test checks that variations of the text which have different casing
are still matched.
"""
text = 'foo'
collection = ['Foo', 'FOO', 'fOO']
matches = completer.find_matches(text, collection)
assert len(matches) == 3