-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-120767: Add REPL history navigation with partial text #121859
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
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
4 similar comments
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Please see also PR gh-123607 and issue gh-119034: it seems like this PR is similar to gh-123607, but different. It's unclear to me if differences are made by purpose or not. I don't know well readline and
@estyxx: Would you mind to play with my PR gh-123607 and see if we can converge to the same behavior? |
For 3.13 we're supporting Page Up and Page Down keys to do strict "current-line prefix search". This supports multiline entries. For your PR, Ester, it's unclear to me what to do in case of multiline entries. WDYT? |
Given that this is supposed to emulate I think this should do the same as arrow up/down because it uses the same bindings as that inputrc file. |
8a29cc7
to
e0d6b53
Compare
This changes add supports to navigate the history with arrow up based on partial text in the buffer
@pablogsal @ambv Regarding multiline commands, I initially wasn't sure if the desired behavior was to skip entire blocks or handle them line by line when navigating. However, after working with the PR, the actual behavior seems okay to me: it displays the multiline commands entirely and navigates line by line, skipping all the lines during the search. I am currently working to fix the tests. While debugging I noticed an unexpected behavior: cc @vstinner Regarding the issue mentioned in the comment here: The behavior works as expected, but in the following case:
The prompt gets stuck to the last match.
as this is the old REPL behavior. I have identified the issue and can fix it in this PR or a separate one. Let me know your preference. To recap, this PR now only rebinds the arrow keys to the same functionality as PageUp and PageDown, i.e., searching the history. |
I don't know how to fix this behavior :-( Feel free to propose a fix. |
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.
To recap, this PR now only rebinds the arrow keys to the same functionality as PageUp and PageDown, i.e., searching the history.
LGTM
Enhance REPL history navigation with partial text support | ||
|
||
The REPL now correctly navigates history based on partial text | ||
in the buffer when using the up arrow. |
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.
Enhance REPL history navigation with partial text support | |
The REPL now correctly navigates history based on partial text | |
in the buffer when using the up arrow. | |
Enhance REPL history navigation with partial text support. | |
The REPL now correctly navigates history based on partial text | |
in the buffer when using the up arrow. |
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.
I'd be careful with the word correctly here, as it could mean many different things.
This behavior is different than Python 3.12 REPL (on Fedora).
If I press UP key, I get I'm not sure which behavior is the most convenient / the least surprising. Should we keep UP/DOWN to only navigate in the history without partial match? cc @hroncok |
I have as many personal opinions on the matter as anyone involved. Sticking to the facts instead:
Footnotes
|
The change is technically correct, but I'm not sure if the change makes sense. I prefer to remove my approval for now.
Hi all, I see that there are many differing opinions regarding the need for this feature. Before proceeding with fixing the tests and investing more time into this, I would like to get a clearer sense of whether the community wants... In the meantime, I’ve identified a related bug which I mentioned in a previous in this comment. �This bug seems to be a definite issue with the current implementation, so I plan to open a separate issue and submit a PR to address it. Please let me know if it’s worth continuing with the current approach or if any adjustments would be more suitable. Thanks in advance for your feedback! |
That sounds like a good idea :-) |
cc @pablogsal
These changes add support for navigating the REPL history with the up arrow key based on partial text in the buffer.
When partial text is in the buffer, the up arrow key will navigate through history entries that start with this partial text.
Example:
This correctly shows
spam = 1
.With the following history:
Typing
a=
and pressing the up arrow key will correctly navigate toa=1
and up.Preserving existing behaviour
The standard navigation remains intact, ensuring that pressing the up arrow key without partial text continues to retrieve the most recent history entry. For example:
first
<arrow-up>
shows2+2
, second<arrow-up>
shows1+1
.