Skip to content

Display linebreaks, TextDisplay vs REPLDisplay #43766

Closed
@t-bltg

Description

@t-bltg

As explained on discourse, we (ping @mkitti) feel that there might be an inconsistency in display(...) between TextDisplay and REPLDisplay.

Does anyone know why there is no trailing newline for TextDisplay ?

Would the following patch be acceptable ?

--- a/base/multimedia.jl	2022-01-11 21:00:42.765702329 +0100
+++ b/base/multimedia.jl	2022-01-11 21:02:53.377249363 +0100
@@ -239,14 +239,14 @@
 struct TextDisplay <: AbstractDisplay
     io::IO
 end
-display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = show(d.io, M, x)
+display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = (show(d.io, M, x); println(d.io))
 display(d::TextDisplay, @nospecialize x) = display(d, MIME"text/plain"(), x)
 
 # if you explicitly call display("text/foo", x), it should work on a TextDisplay:
 displayable(d::TextDisplay, M::MIME) = istextmime(M)
 function display(d::TextDisplay, M::MIME, @nospecialize x)
     displayable(d, M) || throw(MethodError(display, (d, M, x)))
-    show(d.io, M, x)
+    show(d.io, M, x); println(d.io)
 end
 
 import Base: close, flush

Metadata

Metadata

Assignees

No one assigned

    Labels

    display and printingAesthetics and correctness of printed representations of objects.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions