This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients terry.reedy, westley.martinez
Date 2013-09-08.22:19:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378678764.65.0.534392505811.issue18903@psf.upfronthosting.co.za>
In-reply-to
Content
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 ;-).
History
Date User Action Args
2013-09-08 22:19:24terry.reedysetrecipients: + terry.reedy, westley.martinez
2013-09-08 22:19:24terry.reedysetmessageid: <1378678764.65.0.534392505811.issue18903@psf.upfronthosting.co.za>
2013-09-08 22:19:24terry.reedylinkissue18903 messages
2013-09-08 22:19:23terry.reedycreate