Skip to content
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 file completion has 2 bugs depending on open quote used #71862

Open
egerosa mannequin opened this issue Aug 3, 2016 · 6 comments
Open

IDLE file completion has 2 bugs depending on open quote used #71862

egerosa mannequin opened this issue Aug 3, 2016 · 6 comments
Assignees
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@egerosa
Copy link
Mannequin

egerosa mannequin commented Aug 3, 2016

BPO 27675
Nosy @terryjreedy, @csabella
Dependencies
  • bpo-30348: IDLE: Add test_autocomplete unittests
  • bpo-30666: IDLE: add tests for autocomplete window.
  • Files
  • bug_pic.png: png file to show the bug in action in IDLE
  • 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:

    assignee = 'https://github.com/terryjreedy'
    closed_at = None
    created_at = <Date 2016-08-03.15:11:43.700>
    labels = ['expert-IDLE', 'type-bug']
    title = 'IDLE file completion has 2 bugs depending on open quote used'
    updated_at = <Date 2018-05-09.23:20:59.114>
    user = 'https://bugs.python.org/egerosa'

    bugs.python.org fields:

    activity = <Date 2018-05-09.23:20:59.114>
    actor = 'cheryl.sabella'
    assignee = 'terry.reedy'
    closed = False
    closed_date = None
    closer = None
    components = ['IDLE']
    creation = <Date 2016-08-03.15:11:43.700>
    creator = 'egerosa'
    dependencies = ['30348', '30666']
    files = ['43990']
    hgrepos = []
    issue_num = 27675
    keywords = []
    message_count = 6.0
    messages = ['271910', '271924', '271926', '316299', '316312', '316342']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'egerosa', 'cheryl.sabella']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27675'
    versions = ['Python 3.6']

    @egerosa
    Copy link
    Mannequin Author

    egerosa mannequin commented Aug 3, 2016

    A cosmetic bug was noticed when executing os.chdir() in IDLE. When inputting a raw string path in os.chdir() using autocompletion the last directory in the path will remain black if the user presses enter while the autocompletion drop down list is still open. The bug seems to affect only single quoted strings. To reproduce the bug input a raw single quoted string into os.chdir(); select directories through the drop down autocomplete list using Tab; once the destination directory is reached do not make the drop down list disappear, instead after selecting the destination directory type in the closing single quote and brace and hit enter: the final directory in the path will remain black and not turn green. (image file has been added to showcase bug).

    @egerosa egerosa mannequin assigned terryjreedy Aug 3, 2016
    @egerosa egerosa mannequin added topic-IDLE type-bug An unexpected behavior, bug, or error labels Aug 3, 2016
    @terryjreedy
    Copy link
    Member

    When encountering a bug, it helps to determine the minimum needed to invoke the bug. os.chdir is irrelevant and distracting noise as far as investigating these bugs. There turns out to be two. Raw versus cooked mode is also irrelevant, so an 'r' prefix is not needed. The path separator also seems to not matter. So we can use '/'.

    I did several tests with 3.6 on Windows 10, first in Shell, then a quick confirmation in a fresh editor. What does matter is the open quote: ', ", ''', or """. When one types a string without completions, the opening quote along with any prefix is colored, as is the subsequent content and closing quote as they are entered. This should remain true when completions are involved. It is true for opening """ or ". For ''' and ', the first action after typing '/' is colored, subsequent actions are not. The action can be either typing a letter or moving the selection in the completion box with up or down arrow. (Things are different when moving around in a string and forcing completions open with cntl-space.)

    When one types a closing quote, the final directory should be completed if it is not already and the completion box closed. This is true for """ and ", but ''' and ' neither complete nor close. After a ''', additional characters are also colored. For "'''/Ga'''me", the "me" are also, improperly, colored and the box remains.

    We thus have two bugs: a color but that depends on the number of open quotes and a complete and close bug that depends of the type of open quote. A single single quote has both. Thank you for the report.

    Colorizer has a pair of symmetrical regexes for single quote strings (possible not complete) and another pair for triple quote strings. (Symmetrical means identical except for reversing roles of ' and ".) So it is plausible that these might be the cause of a number-dependent bug. It has a debug most that could be turned on doing file completion in an editor.

    @terryjreedy terryjreedy changed the title IDLE does not fully color raw string directory paths to green when invoking os.chdir() if statement is executed with autocompletion drop down list still open IDLE file completion has 2 bugs depending on open quote used Aug 3, 2016
    @terryjreedy
    Copy link
    Member

    Experiments with colorizer debugger on: with auto popup disabled with a
    long wait, output for each character entered is (except for time variations) the following, regardless of quotation.
    schedule colorizing
    colorizing...
    0.002 seconds

    If I type "'/" <tab> for box 'G', I see
    schedule colorizing
    colorizing ...
    but no completion time. An immediate 'a' is not colored and produces
    stop colorizing
    schedule colorizing
    already colorizing

    However, if after entering G, I shift focus off the window, but clicking another window or opening and closing About IDLE, the colorizing completes and I see a time, such as
    41.480 seconds
    and following chars are colorized. If instead, I enter 'a' quickly and then do the shift, I see something like
    colorizing stopped
    58.904 seconds
    and 'a' turns to green, as it should have without the delay.

    Neither of the autocomplete files import colorizer (at least not directly), but the completion box somehow affects colorizing, perhaps through affecting the tk loop.

    If I start with ''' instead of ', the debug output for post-box 'ga' is the same, but 'a' and subsequent chars are colored anyway.

    autocomplete imports hyperparser. but I do not immediately see any asymmetry there or in the autocomplete files to explain why '('') and "("") are treated differently.

    @csabella
    Copy link
    Contributor

    csabella commented May 8, 2018

    I can't seem to recreate this. I tried on Ubuntu with master and Windows with 3.6.3. I'm not sure if it's been fixed by another change or if I'm not doing the steps correctly to recreate it.

    @terryjreedy
    Copy link
    Member

    I believe the report in August 2016 was about the time of the preliminary.0a4 release, months before the final 3.6.0 release. Something could have easily changed after.

    I should have been more detailed and accurate is what I wrote. In paragraph 2, I said I observed the color bug with ' or '''. In paragraph 4, I said that the color bug depended on the number rather than type of quote. The later was accurate.

    My C: directory contains a Logs directory. If in 3.5.4, I type '/, the / is green and the selction box appears. When I type L, the L is green and the selection moves to Logs. When I type o, the o is white (I am using IDLEDark). Or if I backspace and type L, the L is white. Or if I move with the cursor, the inserted word is white.

    This is not true in 3.6.5. The color bug seems fixed. The autocompletion window, which handles interaction when the window is open, was patched in bpo-24570 for a Mac-specific bug.

    The completion bug remains in 3.6.5 and newer. If I type '/L' or '''/L''', L is not completed to Logs and the box does not disappear. The opposite is true for " and """. "/L" completes to "/Logs" and the box goes away. Also, "/L/ completes to "/Logs/, leaving the box open for selection of a subdirectory. "// does not complete to the first item in the box -- at least one action is needed.

    The effect of // is analogous to .. in attribute completion. []. brings up the box. A second . completes the selected name and brings up a new box with subattributes. This does not require an inbetween action.

    Cheryl, is this clear enough to reproduce? It is possible that Linux does not have the bug. It should be in autocomplete_w.py and we already know that this has system-specific behavior.

    I would be reluctant do anything beyond trivial without improving the autocomplete tests. I added bpo-30348 and bpo-30666 as dependencies, at least for the present. This issue is a dependency master autocompletion issue bpo-27609.

    @csabella
    Copy link
    Contributor

    csabella commented May 9, 2018

    Thanks, Terry!

    I'm able to recreate the autocomplete issue on Windows 7 using 3.6.3, but not on Ubuntu. As you said, the color issue seems fine now for both platforms.

    I'll take a look at those other issues for the test cases.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    2 participants