parent
d35effd75d
commit
54c303e07f
|
@ -1,4 +1,4 @@
|
|||
import code, re, string, StringIO, sys, traceback
|
||||
import code, re, string, StringIO, sets, sys, traceback
|
||||
import color, completer, lex, method, mode
|
||||
from lex import Grammar, PatternRule
|
||||
from mode.python import PythonGrammar
|
||||
|
@ -140,11 +140,14 @@ class ConsoleTab(method.Method):
|
|||
def execute(self, w, **vargs):
|
||||
a = w.application
|
||||
s = w.buffer.make_string()
|
||||
l = lex.Lexer(w.mode, PythonGrammar)
|
||||
|
||||
tokens = list(l.lex([s]))
|
||||
x = w.logical_cursor().x
|
||||
#raise Exception, repr(x)
|
||||
if not s or s[:x].isspace():
|
||||
w.insert_string_at_cursor(' ' * w.mode.tabwidth)
|
||||
return
|
||||
|
||||
l = lex.Lexer(w.mode, PythonGrammar)
|
||||
tokens = list(l.lex([s]))
|
||||
|
||||
curr_t = None
|
||||
curr_i = None
|
||||
|
@ -154,7 +157,6 @@ class ConsoleTab(method.Method):
|
|||
curr_i = i
|
||||
curr_t = t
|
||||
if curr_t is None:
|
||||
#raise Exception, 'not found: %r %r' % (x, tokens)
|
||||
return
|
||||
|
||||
first_t = curr_t
|
||||
|
@ -172,6 +174,7 @@ class ConsoleTab(method.Method):
|
|||
else:
|
||||
break
|
||||
|
||||
#raise Exception, repr(names)
|
||||
obj = None
|
||||
g = globals()
|
||||
i = 0
|
||||
|
@ -191,8 +194,15 @@ class ConsoleTab(method.Method):
|
|||
else:
|
||||
break
|
||||
i += 1
|
||||
if obj is not None and i == len(names) - 1:
|
||||
newnames = dir(obj)
|
||||
|
||||
if i == len(names) - 1:
|
||||
if obj is not None:
|
||||
newnames = dir(obj)
|
||||
else:
|
||||
newnames = sets.Set()
|
||||
newnames.update(__builtins__)
|
||||
newnames.update(w.mode.locals)
|
||||
newnames.update(w.mode.globals)
|
||||
candidates = [x for x in newnames if x.startswith(name)]
|
||||
if len(candidates) > 1:
|
||||
s = completer.find_common_string(candidates)[len(name):]
|
||||
|
|
Loading…
Reference in New Issue