parent
019f2645d6
commit
ea3426f235
35
method.py
35
method.py
|
@ -1538,7 +1538,7 @@ class TokenComplete(Method):
|
|||
for t2 in line:
|
||||
if t2 is t:
|
||||
continue
|
||||
elif t2.name not in ok:
|
||||
elif False and t2.name not in ok:
|
||||
continue
|
||||
elif t2.string.startswith(t.string):
|
||||
strings[t2.string] = 1
|
||||
|
@ -1549,25 +1549,40 @@ class TokenComplete(Method):
|
|||
|
||||
strings = strings.keys()
|
||||
if not strings:
|
||||
return (0, t.string)
|
||||
return ([], t.string)
|
||||
|
||||
i = len(t.string)
|
||||
while i < minlen:
|
||||
c = strings[0][i]
|
||||
for s in strings:
|
||||
if s[i] != c:
|
||||
return (len(strings), strings[0][:i])
|
||||
return (strings, strings[0][:i])
|
||||
i += 1
|
||||
return (len(strings), strings[0][:minlen])
|
||||
return (strings, strings[0][:minlen])
|
||||
|
||||
def _execute(self, w, **vargs):
|
||||
t = w.get_token2()
|
||||
if regex.reserved_token_names.match(t.name):
|
||||
|
||||
if t is None:
|
||||
w.set_error("No token to complete!")
|
||||
return
|
||||
elif regex.reserved_token_names.match(t.name):
|
||||
w.set_error("Will not complete reserved token")
|
||||
return
|
||||
|
||||
(n, s) = self._min_completion(w, t)
|
||||
if not n:
|
||||
return
|
||||
(candidates, result) = self._min_completion(w, t)
|
||||
|
||||
# XYZ
|
||||
w.set_error("%r (%r) completing to %r (%d)" % (t.string, t.fqname(), s, n))
|
||||
if candidates:
|
||||
p1 = Point(t.x, t.y)
|
||||
p2 = Point(t.end_x(), t.y)
|
||||
w.buffer.delete(p1, p2)
|
||||
w.insert_string(p1, result)
|
||||
|
||||
if not candidates:
|
||||
w.set_error("No completion: %r" % result)
|
||||
elif len(candidates) == 1:
|
||||
w.set_error("Unique completion: %r" % result)
|
||||
elif result in candidates:
|
||||
w.set_error("Ambiguous completion: %r" % candidates)
|
||||
else:
|
||||
w.set_error("Partial completion: %r" % candidates)
|
||||
|
|
1
mode2.py
1
mode2.py
|
@ -179,6 +179,7 @@ class Fundamental(Handler):
|
|||
self.add_bindings('grep', ('C-c g',))
|
||||
self.add_bindings('pipe', ('C-c p',))
|
||||
self.add_bindings('view-buffer-parent', ('C-c .',))
|
||||
self.add_bindings('token-complete', ('C-c c',))
|
||||
|
||||
# unbound actions
|
||||
self.add_action(method.GetToken())
|
||||
|
|
|
@ -599,7 +599,8 @@ class Window(object):
|
|||
return self.get_token_at_point(self.logical_cursor())
|
||||
def get_token2(self):
|
||||
c = self.logical_cursor()
|
||||
return self.get_token_at_point(Point(min(0, c.x - 1), c.y))
|
||||
p = Point(max(0, c.x - 1), c.y)
|
||||
return self.get_token_at_point(p)
|
||||
def get_token_at_point(self, p):
|
||||
for token in self.get_highlighter().tokens[p.y]:
|
||||
if token.end_x() <= p.x:
|
||||
|
|
Loading…
Reference in New Issue