the problem is that parser/parse-next waits for an enter before returning an object we can use peek-char to pre-emptively react to any EOF at the start of the line in case of not-start-of-line, parse-next takes over Co-authored-by: Alice Margatroid <code@alice.bunkerlabs.net>
This commit is contained in:
parent
dc2502ebae
commit
965c177bca
1 changed files with 8 additions and 7 deletions
|
|
@ -63,13 +63,14 @@
|
|||
(eval-form sci-ctx `(apply require (quote ~m/repl-requires)))))
|
||||
:read (or read
|
||||
(fn [_request-prompt request-exit]
|
||||
(let [v (parser/parse-next sci-ctx in)]
|
||||
(skip-if-eol in)
|
||||
(if (or (identical? :repl/quit v)
|
||||
(identical? :repl/exit v)
|
||||
(identical? parser/eof v))
|
||||
request-exit
|
||||
v))))
|
||||
(if (nil? (r/peek-char in))
|
||||
request-exit
|
||||
(let [v (parser/parse-next sci-ctx in)]
|
||||
(skip-if-eol in)
|
||||
(if (or (identical? :repl/quit v)
|
||||
(identical? :repl/exit v))
|
||||
request-exit
|
||||
v)))))
|
||||
:eval (or eval
|
||||
(fn [expr]
|
||||
(sci/with-bindings {sci/file "<repl>"
|
||||
|
|
|
|||
Loading…
Reference in a new issue