gh-83847: IDLE - Refactor common code between hyperparser and editor#18539
gh-83847: IDLE - Refactor common code between hyperparser and editor#18539csabella wants to merge 4 commits intopython:mainfrom
Conversation
Lib/idlelib/editor.py
Outdated
There was a problem hiding this comment.
'1.0', copied from the old code, seems wrong, as it is the Shell top, before the sign-in message, let alone the first prompt. If one hits Enter at the prompt, I would think that the code should be set to '\n'.
I need to add some prints to be sure of what happens in Shell and editor with various inputs.
There was a problem hiding this comment.
In the shell, it looks like it will always find the last console tag, which is marked from the beginning to the end of the prompt. For example, in a new shell window, typing >>> def hello( without pressing Enter shows r to be (3.0, 3.4).
I wasn't able to think of a scenario where the prompt would be missing in a real shell, so I'm not sure if the default of 1.0 would ever be used there. However, adding a print(r) and running the testsuite shows that the console tag isn't set for most tests, so it falls back to the default.
There was a problem hiding this comment.
Then the shell tests are unrealistic. Of course, with the prompt moved to a sidebar, we should be looking, I believe, for a mark.
There was a problem hiding this comment.
Of course, with the prompt moved to a sidebar, we should be looking, I believe, for a mark.
With the shell moved to a sidebar (PR GH-15474), there's still a "console" tag on the newline (\n) before the beginning of the current input block, making code such as this continue to "just work".
There was a problem hiding this comment.
While we're refactoring this, I think it's a great opportunity to remove the shell-specific part of this code from the EditorWindow class and into PyShell.
|
When you're done making the requested changes, leave the comment: |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
* Move num_context_lines into editor.parser method since it's not used anywhere else.
|
To properly review this, I need to look at EditorWindow chunk, Hyperparser chunk, and new function side-by-side when I have more time. Also see reply on the issue re location of new function. |
|
Closing because I currently prefer #20847 with the new function in hyperparser. |
hyperparser.pyandeditor.pyfor creating a Parser instance that is used for analysis.hyperparserbefore.