diff --git a/pgcli/pgcompleter.py b/pgcli/pgcompleter.py index fddd8e7d..bdf71a5b 100644 --- a/pgcli/pgcompleter.py +++ b/pgcli/pgcompleter.py @@ -223,7 +223,7 @@ class PGCompleter(Completer): pat = re.compile('(%s)' % regex) def _match(item): - r = pat.search(self.unescape_name(item)) + r = pat.search(self.unescape_name(item.lower())) if r: return -len(r.group()), -r.start() else: diff --git a/tests/test_fuzzy_completion.py b/tests/test_fuzzy_completion.py index 6b8e6221..6ec8f5f2 100644 --- a/tests/test_fuzzy_completion.py +++ b/tests/test_fuzzy_completion.py @@ -74,3 +74,16 @@ def test_should_break_ties_using_lexical_order(completer, collection): matches = completer.find_matches(text, collection) 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