Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display newline #763

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,17 @@ 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"
display(d::TextDisplay, M::MIME"text/plain", @nospecialize x) = (show(d.io, M, x); println(d.io))
t-bltg marked this conversation as resolved.
Show resolved Hide resolved
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
end

include("iterators.jl")
include("deprecated.jl")

Expand Down
9 changes: 8 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
end

# https://github.com/JuliaLang/julia/pull/43787
@testset "display" begin
td = TextDisplay(PipeBuffer())
Compat.display(td, 1)
@test read(td.io, String) == "1\n"
end