bhauman/rebel-readline

Flush adds an extra newline

Opened this issue · 1 comments

Hi! It seems that calling (flush) adds an extra newline to the output. Is this expected or is there a way to disable this behavior?

Thanks!

~ :: clj
Clojure 1.9.0
user=> (do (print \.) (flush) (print \.) (flush))
..nil
user=>
~ :: clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"}}}" -m rebel-readline.main
[Rebel readline] Type :repl/help for online help info
user=> (do (print \.) (flush) (print \.) (flush))
.
.
nil

I encountered this also. Looks like it is an intentional behavior to ensure the prompt is displayed properly:

;; still debating about wether to include the following line in

(defn ^java.io.PrintWriter safe-terminal-writer [line-reader]

An alternative might be to read out the cursor positon and insert a newline only if the cursor is not on the first column.