bpo-37903: IDLE: Shell sidebar with prompts (take #2)#22682
Conversation
Specifically, avoid EditorWindow.ResetColorizer() moving the undo and colorizer delegators to the top of the percolator, by removing and inserting them.
This avoids ColorDelegator removing unrelated tags, specifically "stdin", when re-colorizing.
Prompts are now marked in the text by adding the "console" tag to
the newline character ('\n') before the beginning of the line. This
works around issues with the prompt itself usually no longer being
written in the text widget.
With another small fix to the PyShell.recall() method, input lines
can now be recognized consistently by checking for the "stdin" tag.
This is much better than attempting to separately track the prompt
and input lines, since those are difficult to keep up to date after
undo/redo actions and squeezing/unsqueezing of previous output.
The background color still uses that configured for line numbers.
The fix needed was for History to properly set the "stdin" tag on text it inserts.
|
I verified that the double return bug is gone. I will recheck other stuff tomorrow. And also look at the test failure. If the difference of behavior on Windows does not affect Shell's behavior, then maybe the test is not needed. With the main blocker I know of gone, I am hopeful we can get this in the May 3 beta. It would not have to be perfect because I do not expect to immediately backport for the 3.9.5 and 3.8.10 releases on the same day. (Hence, I removed the automatic backport labels.) At this point, I don't mind not putting this in 3.8 (May 4 is its last maintenance release), or delaying putting it in 3.9 (next is 3.9.6 on June 26) until tested and improved. In particular, I would want tab indents gone so users see an immediate benefit that merits having their visual comfort initially disrupted. If you pull a couple of things into separate issues and PRs, then I will deal with news and merging, once satisfied, and baby-sitting the backports. My thinking now is that even if a bug is discovered during and its quick fix is motivated by another issue, it should be done as a separate issue and PR as long as it is applicable to and an upgrade to IDLE as it is. (In otherwords, if we would want it even without the main issue.) Then merge it into the original PR. I should have said something more earlier. |
Sorry, something went wrong.
|
@terryjreedy, I suggest that you wait and let me take another look at the tests. I should find the time for that in the next few days, and hopefully will find a solution that works. If I don't, we can indeed temporarily disable the offending tests, since the issue is entirely with the testing method being fragile (rather than an actual problem with IDLE.) AFAICT after reviewing everything here and the latest fixes and cleanups, there are no other outstanding issues, and there is no need for separate PRs. |
Sorry, something went wrong.
terryjreedy
left a comment
There was a problem hiding this comment.
Name changes and equivalent code replacement.
Sorry, something went wrong.
|
CONFIGDIALOG is disabled because it is still calling update_colors. That line must not be covered in its test. (probably should use some mock_funcs). |
Sorry, something went wrong.
|
@terryjreedy |
Sorry, something went wrong.
|
I am about to get more sleep before continuing. Ignoring the issue of making this work with #25678, discussed on the tracker, do you consider this PR ready to commit for a beta release? |
Sorry, something went wrong.
Yes! I'd like to follow up quickly with implementing mouse interaction with the sidebar (similar to the line-numbers sidebar), including specifically a context-menu (i.e. right-click) option to copy the contents with prompts, which would be useful for doctests for example. |
Sorry, something went wrong.
|
I checked this out and played with it, but while the prompt in the sidebar looks nice, indentation is still with tabs, which gives it a decidedly 1990s feel. :-) |
Sorry, something went wrong.
|
@gvanrossum, thanks for giving this a whirl! Changing indentation from tabs to spaces is a quick followup that @terryjreedy has begun working on (see PR GH-25678). |
Sorry, something went wrong.
|
@terryjreedy, I've got a local branch which refactors |
Sorry, something went wrong.
|
#25678 works to change indents when applied on top of this. I have done a thorough manual testing of the combination. While I want to review these changes more, I am merging this now so we can move on. I will then merge master in #25678 and merge that. Given Tal preference, Guido's comments, and the fact that the changes here are, from a bug-finding viewpoint, more in need of user testing than those in #25678, the sidebar should be in place first. I will look at the new sidebar code after Tal posts a new PR. While trying to make the sidebar optional after adding a 'usesidebar' attribute, I will look at the pyshell changes. Tal, if I have trouble, I will ask for help. |
Sorry, something went wrong.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️Hi! The buildbot s390x Fedora Clang 3.x has failed when building commit 15d3861. What do you need to do:
You can take a look at the buildbot page here: https://buildbot.python.org/all/#builders/3/builds/65 Failed tests:
Failed subtests:
Summary of the results of the build (if available): == Tests result: FAILURE then FAILURE == 410 tests OK. 10 slowest tests:
1 test failed: 15 tests skipped: 1 re-run test: Total duration: 5 min 16 sec Click to see traceback logsTraceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_nntplib.py", line 250, in wrapped
meth(self)
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_nntplib.py", line 293, in test_with_statement
if re.search(r'(?i)KEY.TOO.SMALL', ssl_err.reason):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/re.py", line 178, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
Traceback (most recent call last):
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_nntplib.py", line 277, in test_with_statement
server = self.NNTP_CLASS(self.NNTP_HOST,
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/nntplib.py", line 1025, in __init__
super().__init__(host, port, user, password, readermode,
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/nntplib.py", line 334, in __init__
self.sock = self._create_socket(timeout)
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/nntplib.py", line 1031, in _create_socket
sock = _encrypt_on(sock, self.ssl_context, self.host)
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/nntplib.py", line 292, in _encrypt_on
return context.wrap_socket(sock, server_hostname=hostname)
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/ssl.py", line 518, in wrap_socket
return self.sslsocket_class._create(
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/ssl.py", line 1070, in _create
self.do_handshake()
File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/ssl.py", line 1339, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:969)
|
Sorry, something went wrong.
(Take 2 of this PR, following up PR GH-15474, just to have a cleaner history and conversation, as per @terryjreedy's request.)
This is a working implementation of a sidebar for IDLE's shell, removing the prompts from the main text widget (except for special prompts such as the one used by the debugger.) It works very well in my testing.
Currently known to be missing:
Notes on the implementation:
recall()method.https://bugs.python.org/issue37903