diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2024-06-04 16:09:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-04 16:09:31 (GMT) |
commit | 8fc7653766b106bdbc4ff6154e0020aea4ab15e6 (patch) | |
tree | 3b2873331603a1f2510d4b0067b433c8fc18d81a /Lib/_pyrepl | |
parent | 4dcd91ceafce91ec37bb1a9d544e41fc65578994 (diff) | |
download | cpython-8fc7653766b106bdbc4ff6154e0020aea4ab15e6.zip cpython-8fc7653766b106bdbc4ff6154e0020aea4ab15e6.tar.gz cpython-8fc7653766b106bdbc4ff6154e0020aea4ab15e6.tar.bz2 |
gh-120041: Do not use append_to_screen when completions are visible (GH-120042)
Diffstat (limited to 'Lib/_pyrepl')
-rw-r--r-- | Lib/_pyrepl/commands.py | 7 | ||||
-rw-r--r-- | Lib/_pyrepl/completing_reader.py | 20 |
2 files changed, 18 insertions, 9 deletions
diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py index 2ef5dad..b967f52 100644 --- a/Lib/_pyrepl/commands.py +++ b/Lib/_pyrepl/commands.py @@ -365,7 +365,12 @@ class self_insert(EditCommand): r = self.reader text = self.event * r.get_arg() r.insert(text) - if len(text) == 1 and r.pos == len(r.buffer): + if ( + len(text) == 1 and + r.pos == len(r.buffer) and + not r.cmpltn_menu_visible and # type: ignore[attr-defined] + not r.cmpltn_message_visible # type: ignore[attr-defined] + ): r.calc_screen = r.append_to_screen diff --git a/Lib/_pyrepl/completing_reader.py b/Lib/_pyrepl/completing_reader.py index c11d2da..215ad87 100644 --- a/Lib/_pyrepl/completing_reader.py +++ b/Lib/_pyrepl/completing_reader.py @@ -187,18 +187,20 @@ class complete(commands.Command): if p: r.insert(p) if last_is_completer: - if not r.cmpltn_menu_visible: - r.cmpltn_menu_visible = True + r.cmpltn_menu_visible = True + r.cmpltn_message_visible = False r.cmpltn_menu, r.cmpltn_menu_end = build_menu( r.console, completions, r.cmpltn_menu_end, r.use_brackets, r.sort_in_column) r.dirty = True - elif stem + p in completions: - r.msg = "[ complete but not unique ]" - r.dirty = True - else: - r.msg = "[ not unique ]" - r.dirty = True + elif not r.cmpltn_menu_visible: + r.cmpltn_message_visible = True + if stem + p in completions: + r.msg = "[ complete but not unique ]" + r.dirty = True + else: + r.msg = "[ not unique ]" + r.dirty = True class self_insert(commands.self_insert): @@ -236,6 +238,7 @@ class CompletingReader(Reader): ### Instance variables cmpltn_menu: list[str] = field(init=False) cmpltn_menu_visible: bool = field(init=False) + cmpltn_message_visible: bool = field(init=False) cmpltn_menu_end: int = field(init=False) cmpltn_menu_choices: list[str] = field(init=False) @@ -271,6 +274,7 @@ class CompletingReader(Reader): def cmpltn_reset(self) -> None: self.cmpltn_menu = [] self.cmpltn_menu_visible = False + self.cmpltn_message_visible = False self.cmpltn_menu_end = 0 self.cmpltn_menu_choices = [] |