Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 71662dc

Browse files
taleinatterryjreedy
authored andcommitted
bpo-37849: IDLE: fix completion window positioning above line (GH-15267)
1 parent 4fa10dd commit 71662dc

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Lib/idlelib/NEWS.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Released on 2019-10-20?
33
======================================
44

55

6+
bpo-37849: Fix completions list appearing too high or low when shown
7+
above the current line.
8+
9+
bpo-36419: Refactor autocompete and improve testing.
10+
611
bpo-37748: Reorder the Run menu. Put the most common choice,
712
Run Module, at the top.
813

Lib/idlelib/autocomplete_w.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ def __init__(self, widget):
5252
# (for example, he clicked the list)
5353
self.userwantswindow = None
5454
# event ids
55-
self.hideid = self.keypressid = self.listupdateid = self.winconfigid \
56-
= self.keyreleaseid = self.doubleclickid = None
55+
self.hideid = self.keypressid = self.listupdateid = \
56+
self.winconfigid = self.keyreleaseid = self.doubleclickid = None
5757
# Flag set if last keypress was a tab
5858
self.lastkey_was_tab = False
59+
# Flag set to avoid recursive <Configure> callback invocations.
60+
self.is_configuring = False
5961

6062
def _change_start(self, newstart):
6163
min_len = min(len(self.start), len(newstart))
@@ -223,19 +225,26 @@ def show_window(self, comp_lists, index, complete, mode, userWantsWin):
223225
self.widget.event_add(KEYRELEASE_VIRTUAL_EVENT_NAME,KEYRELEASE_SEQUENCE)
224226
self.listupdateid = listbox.bind(LISTUPDATE_SEQUENCE,
225227
self.listselect_event)
228+
self.is_configuring = False
226229
self.winconfigid = acw.bind(WINCONFIG_SEQUENCE, self.winconfig_event)
227230
self.doubleclickid = listbox.bind(DOUBLECLICK_SEQUENCE,
228231
self.doubleclick_event)
229232
return None
230233

231234
def winconfig_event(self, event):
235+
if self.is_configuring:
236+
# Avoid running on recursive <Configure> callback invocations.
237+
return
238+
239+
self.is_configuring = True
232240
if not self.is_active():
233241
return
234242
# Position the completion list window
235243
text = self.widget
236244
text.see(self.startindex)
237245
x, y, cx, cy = text.bbox(self.startindex)
238246
acw = self.autocompletewindow
247+
acw.update()
239248
acw_width, acw_height = acw.winfo_width(), acw.winfo_height()
240249
text_width, text_height = text.winfo_width(), text.winfo_height()
241250
new_x = text.winfo_rootx() + min(x, max(0, text_width - acw_width))
@@ -256,6 +265,8 @@ def winconfig_event(self, event):
256265
acw.unbind(WINCONFIG_SEQUENCE, self.winconfigid)
257266
self.winconfigid = None
258267

268+
self.is_configuring = False
269+
259270
def _hide_event_check(self):
260271
if not self.autocompletewindow:
261272
return
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed completions list appearing too high or low when shown above
2+
the current line.

0 commit comments

Comments
 (0)