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

Improve history search from console #2771

Closed
jiho opened this issue May 11, 2018 · 4 comments · Fixed by #4813
Closed

Improve history search from console #2771

jiho opened this issue May 11, 2018 · 4 comments · Fixed by #4813

Comments

@jiho
Copy link

@jiho jiho commented May 11, 2018

As noted on community.rstudio.com, it is quite common to remap to do history search based on the currently typed text in the terminal, via .inputrc. R run in a terminal respects this setting.

In RStudio, tying that up to .intputrc might be problematic (especially on Windows) but I think the following default would be safe + nice:

  • Ctrl/Cmd+↑ does history search, with whatever is to the left of the cursor on the current line = opens a modal with the history and the possibility to click through the list (i.e. almost the current behaviour, except that it is restricted it to what is to the left of the cursor; this should be inconsequent in most cases but makes it easier to recover from mistakes -- see below).
  • does history recall = replaces the current command with a command from history, but here also it is restricted to whatever matches what is currently to the left of the cursor. With nothing typed, you get the current behaviour. With something typed you iterate through history, limited to items matching the current text.

For this to work, when the current command line is replaced by a line from history, the cursor should stay in the same place. This does not prevent execution of the code because pressing Enter executes the whole line, no matter where the cursor is.

Example. My history is

foo <- 1
fib <- 2
bar <- 3

Now my prompt looks like this

> f|

where | is the cursor.

Now, Ctrl/Cmd+↑ gives me a modal with

foo <- 1
fib <- 2

and selecting the first (oldest) element of the history fills the command prompt with

> f|oo <- 1

Note the position of the cursor. This way, typing Ctrl/Cmd+↑ again gives me the same options again (because only "f" is to the left of the cursor), which allows me to select a different one in case I clicked wrong.

Typing replaces the command line with

> f|ib <- 2

instead of > bar <- 3| as it would be the case now. Typing again gives

> f|oo <- 1

Of course typing gives back

> f|ib <- 2

I hope this is clear enough. I suppose it is easy enough to explain, less to implement but, well, I am hopeful!

@jmcphers
Copy link
Member

@jmcphers jmcphers commented May 11, 2018

Thanks for this thoughtful writeup, no promises on when we'll implement this but I think it's an excellent idea.

@apsalverda
Copy link

@apsalverda apsalverda commented Aug 15, 2018

I understand that fully implementing this feature request may be fairly complicated.

But would it be possible to implement doing history recall so it only cycles through commands that match what has been typed in so far to the left of the cursor? This would be very useful.

@jiho
Copy link
Author

@jiho jiho commented May 21, 2019

Thank you very much for implementing this! I can't wait for the next version of RStudio to get my hands on it.

@jmcphers
Copy link
Member

@jmcphers jmcphers commented May 24, 2019

Unless you're on MacOS, you can try it now in a daily build! https://dailies.rstudio.com/

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.

3 participants