mordant icon indicating copy to clipboard operation
mordant copied to clipboard

Terminal.println() is a no-op while an animation is running.

Open RafeArnold opened this issue 10 months ago • 0 comments

If the terminal is actively running an animation, the line-feed that should be appended to the console when calling Terminal.println(), or Terminal.println(String) does not get printed. This is due to the terminal interceptors being run before the text is handed to TerminalInterface.completePrintRequest(PrintRequest) where the line-feed is applied.

To reproduce, run the below code in an interactive terminal:

import com.github.ajalt.mordant.animation.textAnimation
import com.github.ajalt.mordant.terminal.Terminal

fun main() {
  val terminal = Terminal()
  val animation = terminal.textAnimation<Unit> { "whatever" }
  animation.update(Unit)
  terminal.println("asdasdasdas\n")
  terminal.println("asdasdasdas")
  terminal.println()
  terminal.println()
  animation.stop()
}

Expected output:

asdasdasdas

asdasdasdas


whatever

Actual output:

asdasdasdas
asdasdasdas
whatever

RafeArnold avatar Apr 14 '25 11:04 RafeArnold