Tab-completion problem in Python2.6 fixed.

In python 2.6 tabcompletion autoappends ( to callables. There is now an
example in startup.py on how to disable this. There was also a bug in 
the completion code that prevented a full list of completions from being
printed in some cases.
This commit is contained in:
Jorgen Stenarson
2010-07-15 23:52:43 +02:00
parent 0fd037b8c0
commit 255e87419a
3 changed files with 24 additions and 10 deletions
+8
View File
@@ -15,6 +15,14 @@ except ImportError:
else:
#import tab completion functionality
import rlcompleter
#Override completer from rlcompleter to disable automatic ( on callable
completer_obj = rlcompleter.Completer()
def nop(val, word):
return word
completer_obj._callable_postfix = nop
readline.set_completer(completer_obj.complete)
#activate tab completion
readline.parse_and_bind("tab: complete")
readline.read_history_file()
+5 -3
View File
@@ -196,13 +196,15 @@ class BaseMode(object):
while 1:
try:
r = ensure_unicode(self.completer(text, i))
except:
except IndexError:
break
i += 1
if r and r not in completions:
if r is None:
break
elif r and r not in completions:
completions.append(r)
else:
break
pass
log(u'text completions=<%s>' % map(ensure_unicode, completions))
if (self.complete_filesystem == "on") and not completions:
# get the filename to complete
+11 -7
View File
@@ -344,19 +344,23 @@ class TestsHistory (unittest.TestCase):
def test_complete (self):
import rlcompleter
logger.sock_silent=False
logger.sock_silent = False
log("-"*50)
r=EmacsModeTest()
r.completer=rlcompleter.Completer().complete
r._bind_key("tab",r.complete)
log("-" * 50)
r = EmacsModeTest()
completerobj = rlcompleter.Completer()
def _nop(val, word):
return word
completerobj._callable_postfix = _nop
r.completer = completerobj.complete
r._bind_key("tab", r.complete)
r.input(u'"exi(ksdjksjd)"')
r.input(u'Control-a')
r.input(u'Right')
r.input(u'Right')
r.input(u'Right')
r.input(u'Tab')
self.assert_line(r,"exit(ksdjksjd)",4)
self.assert_line(r, u"exit(ksdjksjd)", 4)
r.input(u'Escape')
r.input(u'"exi"')
@@ -365,7 +369,7 @@ class TestsHistory (unittest.TestCase):
r.input(u'Right')
r.input(u'Right')
r.input(u'Tab')
self.assert_line(r,"exit",4)
self.assert_line(r, u"exit", 4)