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

Skip to content

bpo-37849: IDLE: fix completion window positioning above line #15267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
15 changes: 13 additions & 2 deletions Lib/idlelib/autocomplete_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Configure> callback invocations.
self.is_configuring = False

def _change_start(self, newstart):
min_len = min(len(self.start), len(newstart))
Expand Down Expand Up @@ -223,19 +225,26 @@ 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 <Configure> callback invocations.
return

self.is_configuring = True
if not self.is_active():
return
# Position the completion list window
text = self.widget
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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed completions list appearing too high or low when shown above
the current line.