Terry J. Reedy added the comment:
The initial difficulty I am having is that the edit menu, help file, code, and
behavior do not seem to match up, so this whole feature set needs more review.
For one thing, the AutoCompleteWindow (ACW) often comes up empty initially.
Sometimes it fills in a couple of seconds later, sometimes not. Or it only
fills in if I enter or delete a char.
However, I did manage to reproduce the issue. (Westley, your ambiguous report
cannot be exactly correct. If you typed 3 chars (no quotes) and tab, you should
get a list of python names, not filenames. If you typed 5 chars (two quotes)
and tab, you should get a literal tab. You would have to type 4 chars (open
quote only) and tab to get filenames.)
Reviewing the code, I see the following.
AutoComplete.open_completions calls .fetch_completions to get a sorted list of
possible completions, according to the mode. It then makes an ACW and calls
.show_window. ACW.show_window receives the mode and stores it as self.mode.
That is used in the logic of ACW.keypress_event for handling 'special'
characters. It is currently not used for matching normal characters to
completions. ACW.show_window also allocates a tk.Listbox with
self.listbox = listbox = Listbox(acw, yscrollcommand=scrollbar.set,
exportselection=False, bg="white")
As near as I can tell, the matching of what the user types with entries in the
ACW listbox is done in ACS._binary_search as items in the listbox seem to be
set with
self.listbox.select_set(self._binary_search(self.start))
For this issue, we need two things.
1. .fetch_completions should sort filenames disregarding case on Windows.
Perhaps key = str.lower will be sufficient, but I do not know what
'case-insensitive' actually means on Windows with respect to general Unicode
file names.
2. A case-insensitive version of _binary_search -- perhaps an instance function
(closure) defined in .show_window using a list of lower-cased entries. Both the
original and replacement should probably use the bisect module, which has a C
accelerator.
There is a third thing: tests. I am reluctant to continue patching Idle without
tests for the issue, but writing one for this will probably be harder than the
patch itself. My main concern is not to make things worse.
It would to easier to document that one should start with one letter and if
there is no desired match, backspace and try the other case ;-).
----------
stage: -> needs patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18903>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com