trptcolin / reply

REPL-y: A fitter, happier, more productive REPL for Clojure.
Eclipse Public License 1.0
337 stars 44 forks source link

Address #166: Set history file max size from inputrc via JLine #183

Closed timmc-bcov closed 6 years ago

timmc-bcov commented 6 years ago

Set history file max size based on inputrc, using newer jline2 to support this configuration.

Please let me know if there are any tests you would like to see.

timmc-bcov commented 6 years ago

OK, this is failing because there's no .inputrc, which I find surprising but I guess not all that surprising. Might be a jline2 bug. -.-

trptcolin commented 6 years ago

I have an inputrc locally and was able to reproduce the failures - I see via lein trampoline run that there's a stack trace on startup (unfortunately it's missing from these test outputs because it's not asserting against @fake-err being empty - that might be a good addition to all these integration tests). Here's what I get:

NumberFormatException null
        java.lang.Integer.parseInt (Integer.java:542)
        java.lang.Integer.parseInt (Integer.java:615)
        reply.reader.simple-jline/default-history-size (simple_jline.clj:76)
        reply.reader.simple-jline/setup-console-reader (simple_jline.clj:98)
        reply.reader.simple-jline/get-input-line (simple_jline.clj:131)
        clojure.lang.Atom.swap (Atom.java:37)
        clojure.core/swap! (core.clj:2232)
        reply.reader.simple-jline/safe-read-line (simple_jline.clj:170)
        reply.reader.simple-jline/safe-read-line (simple_jline.clj:177)
        clojure.core/apply (core.clj:626)
        clojure.core/partial/fn--4228 (core.clj:2468)
        reply.eval-modes.nrepl/run-repl (nrepl.clj:133)

So I think it just needs a failsafe where if "history-size" isn't present, it doesn't try to do the NPE-causing Integer/parseInt - maybe some-> instead of ->?

timmc-bcov commented 6 years ago

Ah, thanks! That explains why I was having trouble isolating this error. I'll put in a fix.

timmc-bcov commented 6 years ago

OK, this works better, and I fixed an additional issue around possibly malformed history-size values (non-numbers) in .inputrc files.

trptcolin commented 6 years ago

Thanks!! 🎉

timmc-bcov commented 6 years ago

And thank you!