Skip to content

Background threads print to the wrong position #2474

@hanshuebner

Description

@hanshuebner

Expected behavior

When "background" threads print to *out*, the output should appear at the end of the buffer, like it does normally. Here's how the bare repl behaves:

Clojure 1.8.0
user=> (do
        (println "before")
        (doto (Thread.
               (fn []
                 (Thread/sleep (rand 500))
                 (println "in thread")))
          (.start)
          (.join))
        (println "after"))
before
in thread
after

Actual behavior

"Background" threads seem to save the position in the buffer when the thread is started and put their *out* starting there:

user>
in thread (do
        (println "before")
        (doto (Thread.
               (fn []
                 (Thread/sleep (rand 500))
                 (println "in thread")))
          (.start)
          (.join))
        (println "after"))
before
after

Note that I only pasted the (do ...) form into the repl, directly after the user> prompt. The output of the thread that was started is printed at a new line, and the input form is moved after that output.

Steps to reproduce the problem

Paste into a cider repl:

(do
        (println "before")
        (doto (Thread.
               (fn []
                 (Thread/sleep (rand 500))
                 (println "in thread")))
          (.start)
          (.join))
        (println "after"))

Environment & Version information

OSX, Clojure 1.8

CIDER version information

;; CIDER 0.16.0 (Riga), nREPL 0.2.13
;; Clojure 1.8.0, Java 1.8.0_101

Lein/Boot version

Leiningen 2.8.1 on Java 1.8.0_101 Java HotSpot(TM) 64-Bit Server VM

Emacs version

GNU Emacs 25.3.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2017-09-12

Operating system

OSX 10.13.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions