Closed d-t-w closed 4 years ago
Interestingly, I can only repeatedly reproduce this bug if I adjust the SEXP in step (2) to be one that definitely does not exist in the REPL history.
Also, I note that at step 6 I need to press the up key twice to get it to move back to show the previous REPL expression.
I just tried this, and I can't reproduce it. Even with a completely new Leiningen project (so no history) this works as I would expect.
Further to @d-t-w's comment, it seems that pressing "UP", etc, works fine if it's the first thing you do. e.g.
However, the issue is there if you then enter a new SEXP.
Oh I see - so the problem is if you have an sexp in the REPL editor and then try to go up? I'll have another go at reproducing this tomorrow.
Hmm, that's not what I meant.
I meant that it seems you have to actually enter a sexp in the editor for the problem to manifest itself.
As in, using 'up', etc to access previous REPL's sexps works fine before you enter a sexp in the current REPL.
Actually, what you describe seems to work fine. I can enter a sexp in the editor and 'up', 'down', etc work fine until I hit 'enter'.
So you have to hit 'enter' (submit the sexp) to reproduce.
@cursive-ide I've been trying to consistently reproduce this. I think I made some progress.
It definitely seems related to the REPL history. It would seem the issue fully manifests only if you enter something which is not in the history. This is easiest to see with unusual stuff you wouldn't otherwise enter.
Example:
.
(that's a dot only)Replace dot with -
, &
, or $
, etc, all by themselves. All of them reproduce as long as it's the first time I'm entering them.
If I follow my original two comments mechanically I can reproduce this bug consistently. Funnily enough I triggered it several times today when pairing.
Basic symptom is 'up doesn't work', basic response is 'type something new into the REPL, now up works again'.
I still can't reproduce this. Are you getting errors in your log when this happens? Help->Show log in Finder/Explorer
@cursive-ide There seems to be nothing, sorry.
When the UP key is not working in the REPL editor, does the "Previous REPL history item" action work? i.e. clicking on the up arrow icon in the REPL toolbar.
Just chiming in after a few test runs to debug the same issue.
@cursive-ide here's an update from me:
Clojure 1.9, Java 1.8, Intellij 2018.2.1, Cursive 1.8.0-eap5-2018.2.
I could not reproduce when creating a brand new project (lein new..) with no history, no dependencies, and typing in a handful of expressions.
I can reproduce when starting a REPL in an active project with lots of dependencies and a fair amount of existing history. I have a number (10+) of different projects with different dependencies for different clients where REPL exhibit this behaviour so I'm not sure it's dependency related as much as "project has lots of history" related.
When I do reproduce, the UP key behaves precisely the same as the "Previous REPL history item" icon in the toolbar in all examples given.
Steps to reproduce are simple enough, few different scenarios:
Scenario 1
Scenario 2
Scenario 3 (basically the same as 2 with slight oddity on first SEXP)
Example: assuming I've no (+ x y) sexp in REPL history
Starting nREPL server...
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -XX:-OmitStackTraceInFastThrow -Dclojure.compile.path=/Users/derek/troy-west/clients/verrency/projects/monitoring-service/target/classes
<...> snip <...>
objc[61615]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x101a484c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x101ad44e0). One of the two will be used. Which one is undefined.
WARNING: Inst already refers to: #'clojure.core/Inst in namespace: schema.core, being replaced by: #'schema.core/Inst
Connecting to local nREPL server...
Clojure 1.9.0
nREPL server started on port 57676 on host 127.0.0.1 - nrepl://127.0.0.1:57676
(+ 18 12)
=> 30 ;; at this point UP does not work, regardless the number of times pressed.
(+ 20 21)
=> 41 ;; at this point UP works on second press
(+ 101 103)
=> 204 ;; at this point UP works on second press
(+ 109 110)
=> 219 ;; at this point UP works on second press
(+ 109 110)
=> 219 ;; at this point UP works first time
(+ 20 21)
=> 41 ;; at this point UP works first time
(+ 1000 1001)
=> 2001 ;; at this point UP works on second press
As @hjrnunes says, I need to type SEXP and execute by pressing enter to trigger changing UP behaviour.
Nothing in Help->Show log in Finder/Explorer
logs
When the UP key is not working in the REPL editor, does the "Previous REPL history item" action work? i.e. clicking on the up arrow icon in the REPL toolbar.
no, clicking on the up arrow does not work either.
It happens to me all the time (for a long time, years). Arrow keys don't work at the REPL start at all in older projects. The workaround is to ctrl-alt-e popup the searchable REPL history and pick the last item there.
It doesn't seem to be related to a project or its size - just the REPL history.
I went on and re-created one of the projects and merged IDEA configurations until a I isolated a single configuration item that causes the issue - it's the component replState
.
When replState
is mostly empty the REPL history (using arrows) works normally. When I copied my old history it stopped working. It could be a long form, big history or something like that.
@cursive-ide repl-history.diff.gz I attach the workspace.xml diff - maybe you'll be able to reproduce the issue.
System: Macbook Pro. Intellij: 2019.1.3 Cursive: 1.8.2-eap4.2019.1
Attached: reproducer workspace.xml.
That's from my IDE when working on cronut.
There are 100 commands in the ReplState component contained in the workspace.xml.
In the scenarios below, the up key and 'previous REPL state' icon have the same behaviour.
Before each scenario I shut Intellij down entirely and start fresh, Intellj caches the workspace.xml and flushes to disk on shutdown.
Scenario 1:
Scenario 2:
Scenario 3:
I thought it might be a gnarly sexp in the history, so I removed the first 50 commands from REPL state, UP key worked fine.
Interested to find the root cause I reverted the original ReplState and removed the last 50 commands from the REPL state, UP key worked fine.
Then I deleted a single entry from the REPL state (99 in history), repeated Scenario 2 and this time UP key worked on the second press.
Closing and restarting a REPL, now with 100 in the history, repeated Scenario 2 and had the original result, UP key no longer works.
Seems like some interplay between appending to history, whether the item exists in the history already, and whether history is full (I presume 100 is the limit).
@cursive-ide
This is fixed! Thanks for the excellent repro cases, this was in fact two different off-by-one errors in different cases, but both when the REPL history was full. Maintaining the REPL history is surprisingly complicated...
Pinnacle of my career being involved in fixing this bug.
I've always entered (+ 1)
into the REPL because it's a short expression and it seems to make the history work again. Never realised it was to do with whether the expression was in my history or not!
Clojure 1.9, Java 1.8, Intellij 2.0.18.1.5, Cursive 1.7.0-2018.1
Apologies for the ridiculously minor bug ticket, but it's mildly annoying and presumably easy to address. Popped up a couple of Cursive releases ago I think.