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
IDLE - tabbing in a string sometimes brings up word completion window #60402
Comments
Pressing <Tab> while the cursor is in a string will bring up the file completion dialog rather than inserting a tab (or 4 spaces). This behavior is rather annoying in a text editor especially when editing multi-line doc strings. This behavior is new to the 3.3 series as a consequence of #59142. Arguably, it is a regression. The logic for bringing up the file completion window when pressing Tab in a string needs to be revised. If the string already contains a partial match, then bring up the window when pressing Tab, otherwise insert a Tab character or spaces. Alternatively, the Ctrl+Space key sequence will already bring up the file completion dialog, so having an automatic Tab completion behavior is not absolutely necessary. This issue can also be triggered in the shell. Start a string and then press tab twice. |
(PATCH - adds 11 lines to autocomplete.py, needs test and conversion to PR. tjr) Attached is a preliminary patch. It checks to see if the cursor is on a line within a multiline string in order to avoid displaying the ACW. As a last resort, it checks to make sure that a valid match exists before opening the ACW when mode == COMPLETE_FILES. |
On windows, one tab brings up the box and in 3.2.3 and 2.7.3 also. Perhaps they should be revised also. The difference is that in those latter two, <space> dismisses the box whereas in 3.3.0, it does not, making it even more obnoxious. Two more tabs inserts something. Tab within a comment just enters a tab converted to spaces. I think that maybe tabs within strings should always do the same as within comments. Perhaps one way is enough. (I am guessing that other editors use <tab> for this, so I can see the desire to use it.) There needs to be a way to get tabbing within multiline strings. I did not see 'file completion' in Options/Configure/Keys. Is it there under a different name? I was puzzled by the example path #59142 until I retried in 3.2.3. In 3.3.0, a / disables filename completion. I reopened this issue. If one types 'd:\' and there is no d:, <tab> inserts spaces and ^space is ignored. I do not like this kind of inconsistency (or magical behavior shift). If you ask for file names, better to bring up a blank box, or a one-line box [<no matches>]. |
There is no configuration option for file completion.
The behavior introduced by the provided patch will only provide the file |
I have had problems entering docstrings because of this. Box should not come us when tab on successive lines. (There really should be autoindent, maybe this interferes.) |
I've found this to be annoying as well especially in docstrings, hopefully this will help in the meantime. If you SHIFT + Tab it will at least resolve the problem of bringing up files and remains as the usual tab function. It makes me wonder if it is a bug at all though? |
It is intentional that <modifier> <tab> be treated as a normal tab. The autocomplete_event tab handler begins with To fix the problem with tabs at the beginning of a line within multiline strings, I am adding to the condition a clause to catch tabs at the beginning of lines, whether within a multiline string or not.
Tests still pass with this addition. I need to add a test that fails without it. I think a tab should bring up completion box even immediately after an opening quote, as in |
I pushed a patch on another issue that fixed tabbing on lines after the first line within multiline strings. With 3.6 and 3.11 I verified that tabbing anywhere on the same line of an opening quote, except immediately after the quote, brings up the box. |
My local branch strcomp currently has a slight revision of the 'match' part of Roger's patch, and it seems to work as promised. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: