X Tutup
Skip to content

Commit acde8ab

Browse files
curtsies working again
1 parent c9c0cbf commit acde8ab

File tree

3 files changed

+116
-188
lines changed

3 files changed

+116
-188
lines changed

bpython/cli.py

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -465,21 +465,20 @@ def complete(self, tab=False):
465465
self.scr.touchwin() #TODO necessary?
466466
return
467467

468-
if self.config.auto_display_list or tab:
469-
list_win_visible = repl.Repl.complete(self, tab)
470-
if list_win_visible:
471-
try:
472-
self.show_list(self.matches_iter.matches, topline=self.argspec, formatter=self.matches_iter.completer.format)
473-
except curses.error:
474-
# XXX: This is a massive hack, it will go away when I get
475-
# cusswords into a good enough state that we can start
476-
# using it.
477-
self.list_win.border()
478-
self.list_win.refresh()
479-
list_win_visible = False
480-
if not list_win_visible:
481-
self.scr.redrawwin()
482-
self.scr.refresh()
468+
list_win_visible = repl.Repl.complete(self, tab)
469+
if list_win_visible:
470+
try:
471+
self.show_list(self.matches_iter.matches, topline=self.argspec, formatter=self.matches_iter.completer.format)
472+
except curses.error:
473+
# XXX: This is a massive hack, it will go away when I get
474+
# cusswords into a good enough state that we can start
475+
# using it.
476+
self.list_win.border()
477+
self.list_win.refresh()
478+
list_win_visible = False
479+
if not list_win_visible:
480+
self.scr.redrawwin()
481+
self.scr.refresh()
483482

484483
def clrtobol(self):
485484
"""Clear from cursor to beginning of line; usual C-u behaviour"""
@@ -510,31 +509,6 @@ def cut_to_buffer(self):
510509
self.scr.redrawwin()
511510
self.scr.refresh()
512511

513-
def cw(self):
514-
"""Return the current word, i.e. the (incomplete) word directly to the
515-
left of the cursor"""
516-
517-
# I don't know if autocomplete should be disabled if the cursor
518-
# isn't at the end of the line, but that's what this does for now.
519-
if self.cpos: return
520-
521-
# look from right to left for a bad method or dictionary character
522-
l = len(self.s)
523-
is_method_char = lambda c: c.isalnum() or c in ('.', '_')
524-
dict_chars = ['[']
525-
526-
if not self.s or not (is_method_char(self.s[-1])
527-
or self.s[-1] in dict_chars):
528-
return
529-
530-
for i in range(1, l+1):
531-
c = self.s[-i]
532-
if not (is_method_char(c) or c in dict_chars):
533-
i -= 1
534-
break
535-
536-
return self.s[-i:]
537-
538512
def delete(self):
539513
"""Process a del"""
540514
if not self.s:
@@ -1458,12 +1432,13 @@ def tab(self, back=False):
14581432
# 2. run complete() if we aren't already iterating through matches
14591433
if not self.matches_iter:
14601434
self.complete(tab=True)
1435+
self.print_line(self.s)
14611436

14621437
# 3. check to see if we can expand the current word
14631438
if self.matches_iter.is_cseq():
1464-
_, self.s = self.matches_iter.substitute_cseq()
1439+
self.cursor_offset, self.s = self.matches_iter.substitute_cseq()
14651440
self.print_line(self.s)
1466-
if not self.matches_iter and self.config.auto_display_list:
1441+
if not self.matches_iter:
14671442
self.complete()
14681443

14691444
# 4. swap current word for a match list item

0 commit comments

Comments
 (0)
X Tutup