[SI-1067] Interpreter (aka REPL) history should be by statement, not by textual line. Created: 25/Jun/08  Updated: 27/Jan/16

Status: Open
Project: Scala Programming Language
Component/s: Repl / Interpreter
Affects Version/s: None
Fix Version/s: Backlog

Type: Bug Priority: Minor
Reporter: Geoffrey Alan Washburn Assignee: Unassigned
Resolution: Unresolved Votes: 4
Labels: community


Issue Links:
relates to SI-7637 REPL :edit command CLOSED


If you write the following in the interpreter:

scala> trait A {
     |   val x : String
     | }
defined trait A

And use up-arrow (or whatever your particular binding is), you get

scala> }

Which is nearly useless. The history should instead group an entire statement. For example, in zsh, if you write:

% for i in *.xml
for> wc -c $$i
8866 build.examples.xml
46544 build.xml

Then hitting up arrow gives you:

% for i in *.xml
wc -c $$i

rlwrap is not smart enough to either, it would probably require more configurability than is reasonable for it to offer, so we should fix the interaction with jline to get the more useful behavior.

Comment by Martin Odersky [ 14/Jan/09 ]

Milestone next_feature deleted

Comment by Paul Phillips [ 14/Dec/09 ]

At some point I implemented the logic for this, but the real obstacle is jline. It has enough trouble figuring out where the cursor is under the simplest conditions. Start throwing big multiline blocks into the history and it breaks down in tears. Would love to see this and SI-2547 addressed by the community.

Comment by Seth Tisue [ 23/Jul/10 ]

close as wontfix?

Comment by Paul Phillips [ 23/Jul/10 ]

I expect to fix this soon too, but it depends on how well the recent jline work goes. I implemented it long ago, and display issues are the impediment.

Comment by Seth Tisue [ 04/Aug/11 ]

At the time this ticket was created Paul hadn't yet added the :paste feature to the REPL. Now that it exists this ticket is even more relevant.

Stuff pasted into the REPL via :paste probably shouldn't become part of the history when you up-arrow through it. I'm typically pasting 5 or 10 or 20 or 50 lines of code, and it's annoying to have to up-arrow through all that stuff to get to the last expression I actually typed myself with my fingers.

I can imagine this might not be totally trivial to implement since :paste'd code should certainly be considered part of the history for :replay purposes, just not for up-arrow-ing purposes.

I'm adding this as a comment on this ticket, but it isn't strictly the same issue. If fixing JLine not to choke on multiline stuff is too hard, then it would still be very nice to have the "don't up-arrow into pastes" change just by itself.

Comment by A. P. Marki [ 26/Aug/14 ]

I always wondered what the world was like right after 1066, and now I see that 1067 wasn't so different from today.

Comment by Li Haoyi [ 19/Apr/15 ]

This has been fixed in the Ammonite REPL.

@ trait A{
    val x: String
defined trait A
@ <UP>
@ trait A{
  val x: String
defined trait A

It looks kind of awkward sometimes, but it does work

Comment by Hamish Dickson [ 27/Jan/16 ]

Is this something people are still interested in? I've been looking for something to work on and would be happy to investigate

Generated at Fri Oct 19 11:21:58 CEST 2018 using JIRA 7.9.1#79001-sha1:60970b42586a2ec2760ed6cfe825b26961e62b9e.