Skip to content
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

Feature request: Julia-style "next command" down key in the REPL #781

Open
ageron opened this issue Jul 6, 2024 · 3 comments · May be fixed by #782
Open

Feature request: Julia-style "next command" down key in the REPL #781

ageron opened this issue Jul 6, 2024 · 3 comments · May be fixed by #782

Comments

@ageron
Copy link

ageron commented Jul 6, 2024

Julia's REPL has a really nice feature: when you press the <down> key and you just picked and executed command #N in the history, then the REPL will select command #N+1 in the history (assuming you haven't pressed <up> yet).

For example:

julia> 1+1
2
julia> 2+2
4
julia> 3+3
6
julia> 4+4
8
julia> 2+2        #<-- this command was selected in the history by typing <up><up><up>
4
julia> 3+3        #<-- this command was selected simply by typing <down> (instead of <up><up><up>)
6
julia> 4+4        #<-- this command was also selected simply by typing <down> (instead of <up><up><up>)
8

Rationale: it's very common to execute several commands in a row from the history (perhaps skipping or editing a few of them). If these commands are far up in the history, then it's cumbersome to have to go back up for each one of them. Thanks to this "next command" feature, you only need to go back up for the command #N, then for every subsequent command, you just press once (or several times if you want to skip some commands).

It's probably not very hard to implement, and it's a real pleasure to use (git it a try!). Plus it won't break any user's expectations since this scenario currently does nothing at all.

@gwenn
Copy link
Collaborator

gwenn commented Jul 7, 2024

The history_index is lost/reset each time you press enter / validate the line.

If we keep this history_index state, we must ensure that it is invalidated if History is cleared / reloaded / ...

  • check other similar libraries (I almost sure that linenoise behaves like rustyline because rustyline was based on linenoise but readline behaves like you describe)
  • check if this behaviour makes sense when history entries are immutable
  • enhance History trait ?

@gwenn
Copy link
Collaborator

gwenn commented Jul 7, 2024

@gwenn gwenn linked a pull request Jul 7, 2024 that will close this issue
3 tasks
@gwenn
Copy link
Collaborator

gwenn commented Oct 27, 2024

Would you mind reviewing / testing #782 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants