Skip to content

Commit 2d34994

Browse files
only call update_completion once when adding a character
1 parent 0db42ff commit 2d34994

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,12 @@ def add_normal_character(self, char):
753753
if self.incremental_search_mode:
754754
self.add_to_incremental_search(char)
755755
else:
756-
self.current_line = (self.current_line[:self.cursor_offset] +
757-
char +
758-
self.current_line[self.cursor_offset:])
756+
self._set_current_line((self.current_line[:self.cursor_offset] +
757+
char +
758+
self.current_line[self.cursor_offset:]),
759+
update_completion=False,
760+
reset_rl_history=False,
761+
clear_special_mode=False)
759762
self.cursor_offset += 1
760763
if self.config.cli_trim_prompts and self.current_line.startswith(self.ps1):
761764
self.current_line = self.current_line[4:]
@@ -1232,14 +1235,13 @@ def _get_cursor_offset(self):
12321235
def _set_cursor_offset(self, offset, update_completion=True, reset_rl_history=False, clear_special_mode=True):
12331236
if self._cursor_offset == offset:
12341237
return
1235-
if update_completion:
1236-
self.update_completion()
12371238
if reset_rl_history:
12381239
self.rl_history.reset()
12391240
if clear_special_mode:
12401241
self.incremental_search_mode = None
12411242
self._cursor_offset = offset
1242-
self.update_completion()
1243+
if update_completion:
1244+
self.update_completion()
12431245
self.unhighlight_paren()
12441246
cursor_offset = property(_get_cursor_offset, _set_cursor_offset, None,
12451247
"The current cursor offset from the front of the line")

bpython/repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def set_docstring(self):
629629
self.docstring = None
630630

631631
def complete(self, tab=False):
632-
"""Construct a full list of possible completions and construct and
632+
"""Construct a full list of possible completions and
633633
display them in a window. Also check if there's an available argspec
634634
(via the inspect module) and bang that on top of the completions too.
635635
The return value is whether the list_win is visible or not.

0 commit comments

Comments
 (0)