[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-26 Thread Lewis Ball
Lewis Ball added the comment: Okay that makes sense. Removing things from _synchre would slow down the matching slightly, although the matching still seems plenty fast enough when done inside an if clause at the moment, so I'm not sure how noticeable the removal of `else` would be. One thing

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-25 Thread Terry J. Reedy
Terry J. Reedy added the comment: As I at least hinted above, I would rather add the missing line starts than delete more. I am quite sure that their absence degrades overall performance in some sense. A much bigger match problem that this one is that ^0 always half fails when the cursor i

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-25 Thread Lewis Ball
Lewis Ball added the comment: Okay, on further examination `find_good_parse_start` first looks for a line ending with ':\n', and then looks to match _synchre on that line. If it can't find any line ending in ':\n' then it will just look for the first occurrence of something in _synchre to tr

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-25 Thread Lewis Ball
Lewis Ball added the comment: So it looks like `pyparse.Parser.find_good_parse_start` is responsible for truncating the code to only look for the matching bracket in the current statement, which uses _synchre. Testing it out, it sometimes will go to the most recent match of _synchre, but wi

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: Lewis, removing you was an accident. Your post is correct. -- ___ Python tracker ___ ___ Python-

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Terry J. Reedy
Change by Terry J. Reedy : -- nosy: +Lewis Ball ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: Without rereading hyperparser and pyparse, I don't understand why a previous _synchre match prevents subsequent failures. It does suggest that when matching parentheses, a fix would be to temporarily prepend 'else\n' to the text, or otherwise simulating the

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: (While I wrote the following, Lewis Ball posted some of the same conclusions.) 0. I verified the failure with 3.8.5 and current master. 1. I reduced the failing example to a minimum of 7 chars on 2 lines. ( else) 1a. Deleting '\n' or any letter of 'else' fix

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Lewis Ball
Lewis Ball added the comment: A minimal example of the same issue seems to be: ``` (1 if x else 0) ``` In this case the parentheses matching also fails. It only ever seems to fail when `else` is the first word on a newline inside brackets, and adding the line break elsewhere in the above sta

[issue41388] IDLE fails to detect corresponding opening parenthesis

2020-07-24 Thread Alexey Burdin
New submission from Alexey Burdin : ``` answers_field_order=sorted( set(j for i in data['items'] for j in i), key=cmp_to_key(lambda x,y:( -1 if (x,y) in answer_order else (0 if x==y else 1))) ) ``` when the cursor is placed in line 5 col 31 (between `)` and `))`