-
Notifications
You must be signed in to change notification settings - Fork 230
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
Cmdline history: deque, restore input command, ability to use up/down arrow keys #600
Conversation
Converting to draft to avoid mistakes.
I agree that arrow keys are more discoverable. Let's just switch it over for everyone. Maybe add shift-page up/down (or so) for history scrollback. (It should still also be available as Cursor right (go to 'clear' button) and then up/down.) |
In case you want a setting option, I started to hack something together:
Sure.
It is. I also intended to write it next to the proposed setting, like in the screenshot. |
6c4eeeb
to
536db4a
Compare
I think the instant-apply logic for that setting will be cumbersome/hard to maintain. Let's just switch it over. |
This changes the arow keys from accessing the command line results to browsing the command history, as requested by the main developer: inducer#600 (comment)
536db4a
to
8833e50
Compare
This changes the arow keys from accessing the command line results to browsing the command history, as requested by the main developer: inducer#600 (comment)
8833e50
to
43605e5
Compare
One thing still remains: I am not sure what the behavior should be when:
How would I do that? Add a keybinding that calls |
I think that's fine.
How about just send a "Page-Up" keypress to the widget? (without changing focus) Not sure if that'll work, but it may. |
So the idea is to scroll / browse the results scrollback, but leaving the focus in the prompt? Interesting, I will try that. |
I am having trouble sending a keypress to an unfocused widget. Alternatively, the docs recommend to scroll A related question: https://stackoverflow.com/questions/49416332/focus-widget-in-list-but-keep-cursor-in-another/49520580, but that seems to jump result-wise again.
By researching the keypress stuff, I stumbled across this: |
Thanks for exploring. Given the apparent difficulty, I think it might be best to leave making the history scrollback more efficient out of scope for now. |
This changes the arow keys from accessing the command line results to browsing the command history, as requested by the main developer: inducer#600 (comment)
43605e5
to
6c0c11f
Compare
Let me know what you think! |
6c0c11f
to
16d2c97
Compare
Hi! Just wondering if there's still anything to be done on my end do get this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Could you rebase and add docs for Shift+Pg{Up,Dn}?
for key in ("page up", "page down"): | ||
self.cmdline_sigwrap.listen("shift " + key, cmdline_results_scroll) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document these keystrokes?
A deque handles the size limit internally, eliminating some logic in the debugger itself.
Text input to the internal command line is now restored and not lost after browsing the history. It is designed to behave just like a dedicated history item at the end of the history. This matches the behavior of readline in most shells. For example, writing a command without executing it, then moving up to the most recent history item and down again restores the typed command. The pudb special behavior of clearing the command when moving down from the end of the history is also preserved. In that case the text can be restored too by moving up in the history again before typing anything new. This is akin to using Ctrl-C in common shells to clear the current command, but with the ability to restore the input again. Using the clear button which empties the displayed shell history now also clears the command input, since it can be easily restored. This fixes one of my pain points with the internal pudb command line: When writing a lengthy command, accidentally hitting Ctrl-N or Ctrl-P overwrites the input text field with no possibility to get the content back. This is particularly bad after using vim's word completion with Ctrl-N for an extensive amount of time, and then accidentally hitting the same shortcut in pudb instead of tab completion.
This changes the arow keys from accessing the command line results to browsing the command history, as requested by the main developer: inducer#600 (comment)
There is the - command history, which stores previously executed commands - result scrollback, which refers to list of shell prompts and their results The latter one was previously called 'command line history'. To avoid confusion, this commit introduces a major new term.
After executing a command, immediatly hitting the arrow up key should recall the just executed command again, like in all shells. This commit ensures this behavior by clearing out the saved edit text on successful command execution. Previously, it recalled the last saved edit text if set, which is an annoying workflow break compared to other shells.
16d2c97
to
6a1e11d
Compare
Sorry for the delay. I added docs and rebased it, it should merge now. While testing the new results browse function, I experienced some UI glitches sometimes. |
This changes the arow keys from accessing the command line results to browsing the command history, as requested by the main developer: #600 (comment)
Thanks! |
This PR aims to change three things related to the internal command line history:
collections.deque
for the history storage: This handles the maximum size internally, automatically deleting old entries onappend()
I just found a deque a nice fit for the use case while working on the other features, but there is no absolute need for this change.
This fixes one of my pain points in pudb: When accidentally hitting Ctrl-N in the command line, it deletes my potentially long command input with no possibility to get it back.
This is my other pain point in the pudb internal shell: After not being aware for a year that browsing the history is even possible, I still find Ctrl-N/P highly unfamiliar despite using pudb for multiple years now. I still press the arrow keys now and then.