Skip to content

Commit 8b4b634

Browse files
committed
Do not display suggestions inside strings (without tab pressed).
1 parent 8f659de commit 8b4b634

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

bpython/cli.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,9 @@ def complete(self, tab=False):
738738

739739
if OPTS.auto_display_list or tab:
740740
self.list_win_visible = self._complete(tab)
741+
if not self.list_win_visible:
742+
self.scr.redrawwin()
743+
self.scr.refresh()
741744
return
742745

743746
def _complete(self, tab=False):
@@ -748,18 +751,15 @@ def _complete(self, tab=False):
748751

749752
if not self.get_args():
750753
self.argspec = None
754+
self.docstring = None
751755

752756
cw = self.cw()
753757
cs = self.current_string()
754-
if not (cw or cs or self.argspec):
755-
self.matches_iter.update()
756-
self.scr.redrawwin()
757-
self.scr.refresh()
758-
return False
759-
760758
if not cw:
761759
self.matches = []
762760
self.matches_iter.update()
761+
if not (cw or cs or self.argspec):
762+
return False
763763

764764
if cs and tab:
765765
# Filename completion
@@ -772,15 +772,18 @@ def _complete(self, tab=False):
772772
filename = '~' + filename[len(user_dir):]
773773
self.matches.append(filename)
774774
self.matches_iter.update(cs, self.matches)
775-
return True
775+
return bool(self.matches)
776+
elif cs:
777+
# Do not provide suggestions inside strings, as one cannot tab
778+
# them so they would be really confusing.
779+
return False
776780

777781
# Check for import completion
778782
e = False
779783
matches = importcompletion.complete(self.s, cw)
780784
if matches is not None and not matches:
781785
self.matches = []
782786
self.matches_iter.update()
783-
self.scr.redrawwin()
784787
return False
785788

786789
if matches is None:
@@ -796,13 +799,10 @@ def _complete(self, tab=False):
796799
else:
797800
matches = self.completer.matches
798801

799-
self.docstring = None
800-
801802
if e or not matches:
802803
self.matches = []
803804
self.matches_iter.update()
804805
if not self.argspec:
805-
self.scr.redrawwin()
806806
return False
807807
if self.current_func is not None:
808808
self.docstring = pydoc.getdoc(self.current_func)

0 commit comments

Comments
 (0)