From b31fa48af8ff940e6dc5d47c13ff026a12dace18 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Wed, 14 Aug 2019 09:45:01 +0300 Subject: [PATCH 1/4] bpo-37849: fix completion window positioning above line Added a mechanism to avoid multiple, recursive invocations of the "" event handler, required due to the added .update() call. --- Lib/idlelib/autocomplete_w.py | 15 +++++++++++++-- .../IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst diff --git a/Lib/idlelib/autocomplete_w.py b/Lib/idlelib/autocomplete_w.py index c69ab4a3683630..5035e067392e5f 100644 --- a/Lib/idlelib/autocomplete_w.py +++ b/Lib/idlelib/autocomplete_w.py @@ -52,10 +52,12 @@ def __init__(self, widget): # (for example, he clicked the list) self.userwantswindow = None # event ids - self.hideid = self.keypressid = self.listupdateid = self.winconfigid \ - = self.keyreleaseid = self.doubleclickid = None + self.hideid = self.keypressid = self.listupdateid = \ + self.winconfigid = self.keyreleaseid = self.doubleclickid = None # Flag set if last keypress was a tab self.lastkey_was_tab = False + # Flag set to avoid recursive callback invocations. + self.is_configuring = False def _change_start(self, newstart): min_len = min(len(self.start), len(newstart)) @@ -223,12 +225,18 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin): self.widget.event_add(KEYRELEASE_VIRTUAL_EVENT_NAME,KEYRELEASE_SEQUENCE) self.listupdateid = listbox.bind(LISTUPDATE_SEQUENCE, self.listselect_event) + self.is_configuring = False self.winconfigid = acw.bind(WINCONFIG_SEQUENCE, self.winconfig_event) self.doubleclickid = listbox.bind(DOUBLECLICK_SEQUENCE, self.doubleclick_event) return None def winconfig_event(self, event): + if self.is_configuring: + # Avoid running on recursive callback invocations. + return + + self.is_configuring = True if not self.is_active(): return # Position the completion list window @@ -236,6 +244,7 @@ def winconfig_event(self, event): text.see(self.startindex) x, y, cx, cy = text.bbox(self.startindex) acw = self.autocompletewindow + acw.update() acw_width, acw_height = acw.winfo_width(), acw.winfo_height() text_width, text_height = text.winfo_width(), text.winfo_height() new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width)) @@ -256,6 +265,8 @@ def winconfig_event(self, event): acw.unbind(WINCONFIG_SEQUENCE, self.winconfigid) self.winconfigid = None + self.is_configuring = False + def _hide_event_check(self): if not self.autocompletewindow: return diff --git a/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst b/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst new file mode 100644 index 00000000000000..87310c1041e852 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst @@ -0,0 +1 @@ +Fixed completions list appearing too high when shown above the current line. From 7b2a2383b20e9557730190517a3325c38772f250 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 14 Aug 2019 03:00:20 -0400 Subject: [PATCH 2/4] Update 2019-08-14-09-43-15.bpo-37849.-bcYF3.rst --- Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst b/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst index 87310c1041e852..9f700d9031f149 100644 --- a/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst +++ b/Misc/NEWS.d/next/IDLE/2019-08-14-09-43-15.bpo-37849.-bcYF3.rst @@ -1 +1,2 @@ -Fixed completions list appearing too high when shown above the current line. +Fixed completions list appearing too high or low when shown above +the current line. From 7e6c4b7bec5ef5a54ac68bb5f49979dd320becb8 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Wed, 14 Aug 2019 11:12:28 +0300 Subject: [PATCH 3/4] add an entry in Lib/idlelib/NEWS.txt --- Lib/idlelib/NEWS.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 0fff7003b9d6b0..d83365ef061f91 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -232,6 +232,9 @@ coverage of each test. bpo-33856: Add 'help' to Shell's initial welcome message. +bpo-37849: Fix completions list appearing too high or low when shown +above the current line. + What's New in IDLE 3.7.0 (since 3.6.0) Released on 2018-06-27 From 2d187110424ad4f79c6b49c6d60accfeeed1c8e6 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Wed, 14 Aug 2019 12:43:12 -0400 Subject: [PATCH 4/4] Update NEWS.txt --- Lib/idlelib/NEWS.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index d83365ef061f91..45918cf36b4193 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -3,6 +3,11 @@ Released on 2019-10-20? ====================================== +bpo-37849: Fix completions list appearing too high or low when shown +above the current line. + +bpo-36419: Refactor autocompete and improve testing. + bpo-37748: Reorder the Run menu. Put the most common choice, Run Module, at the top. @@ -232,9 +237,6 @@ coverage of each test. bpo-33856: Add 'help' to Shell's initial welcome message. -bpo-37849: Fix completions list appearing too high or low when shown -above the current line. - What's New in IDLE 3.7.0 (since 3.6.0) Released on 2018-06-27