Issue #23441: rcompleter now prints a tab character instead of displaying

possible completions for an empty word.

Initial patch by Martin Sekera.
This commit is contained in:
Berker Peksag 2015-07-28 00:08:24 +03:00
commit 0659c43d73
3 changed files with 17 additions and 0 deletions

View File

@ -73,6 +73,12 @@ class Completer:
if self.use_main_ns: if self.use_main_ns:
self.namespace = __main__.__dict__ self.namespace = __main__.__dict__
if not text.strip():
if state == 0:
return '\t'
else:
return None
if state == 0: if state == 0:
if "." in text: if "." in text:
self.matches = self.attr_matches(text) self.matches = self.attr_matches(text)

View File

@ -64,5 +64,13 @@ class TestRlcompleter(unittest.TestCase):
['egg.{}('.format(x) for x in dir(str) ['egg.{}('.format(x) for x in dir(str)
if x.startswith('s')]) if x.startswith('s')])
def test_complete(self):
completer = rlcompleter.Completer()
self.assertEqual(completer.complete('', 0), '\t')
self.assertEqual(completer.complete('a', 0), 'and')
self.assertEqual(completer.complete('a', 1), 'as')
self.assertEqual(completer.complete('as', 2), 'assert')
self.assertEqual(completer.complete('an', 0), 'and')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -42,6 +42,9 @@ Core and Builtins
Library Library
------- -------
- Issue #23441: rcompleter now prints a tab character instead of displaying
possible completions for an empty word. Initial patch by Martin Sekera.
- Issue #24683: Fixed crashes in _json functions called with arguments of - Issue #24683: Fixed crashes in _json functions called with arguments of
inappropriate type. inappropriate type.