From c19893fa2081ecb4bd0c5d35af07d960ae8038fb Mon Sep 17 00:00:00 2001 From: t-bltg <tf.bltg@gmail.com> Date: Tue, 18 Jan 2022 14:45:47 +0100 Subject: [PATCH 1/2] display newline --- src/Compat.jl | 10 ++++++++++ test/runtests.jl | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Compat.jl b/src/Compat.jl index 33af9ae62..110be5360 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1314,6 +1314,16 @@ if VERSION < v"1.8.0-DEV.487" eachsplit(str::AbstractString; limit::Integer=0, keepempty=false) = eachsplit(str, isspace; limit=limit, keepempty=keepempty) end + +# https://github.com/JuliaLang/julia/pull/43787 +if VERSION < v"1.8.0-DEV.1310" + Base.display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = (show(d.io, M, x); println(d.io)) + function Base.display(d::TextDisplay, M::MIME, @nospecialize x) + displayable(d, M) || throw(MethodError(display, (d, M, x))) + show(d.io, M, x); println(d.io) + end +end + include("iterators.jl") include("deprecated.jl") diff --git a/test/runtests.jl b/test/runtests.jl index ecf9119fe..852c999bb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1370,4 +1370,11 @@ so, these are the Base.split tests, but replacing split with eachsplit |> collec eachsplit("α β γ", isspace) |> collect == rsplit("α β γ", isspace) == ["α","β","γ"] @test eachsplit("ö.", ".") |> collect == rsplit("ö.", ".") == ["ö",""] @test eachsplit("α β γ", "β") |> collect == rsplit("α β γ", "β") == ["α "," γ"] -end \ No newline at end of file +end + +# https://github.com/JuliaLang/julia/pull/43787 +@testset "display" begin + td = TextDisplay(PipeBuffer()) + display(td, 1) + @test read(td.io, String) == "1\n" +end From 4f61b59ff8237871845dadbe3916051a64172f18 Mon Sep 17 00:00:00 2001 From: t-bltg <tf.bltg@gmail.com> Date: Tue, 18 Jan 2022 14:58:21 +0100 Subject: [PATCH 2/2] Base.display -> Compat.display --- src/Compat.jl | 5 +++-- test/runtests.jl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index 110be5360..d25a01ce1 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1317,8 +1317,9 @@ end # https://github.com/JuliaLang/julia/pull/43787 if VERSION < v"1.8.0-DEV.1310" - Base.display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = (show(d.io, M, x); println(d.io)) - function Base.display(d::TextDisplay, M::MIME, @nospecialize 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) + function display(d::TextDisplay, M::MIME, @nospecialize x) displayable(d, M) || throw(MethodError(display, (d, M, x))) show(d.io, M, x); println(d.io) end diff --git a/test/runtests.jl b/test/runtests.jl index 852c999bb..46cdb1b75 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1375,6 +1375,6 @@ end # https://github.com/JuliaLang/julia/pull/43787 @testset "display" begin td = TextDisplay(PipeBuffer()) - display(td, 1) + Compat.display(td, 1) @test read(td.io, String) == "1\n" end