Skip to content

Commit ac10640

Browse files
author
KristofferC
committed
propagate the terminals displaysize to the IOContext used by the REPL
1 parent 67c1723 commit ac10640

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

base/strings/io.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ function show(
208208
get(io, :limit, false)::Bool || return show(io, str)
209209
limit = max(20, displaysize(io)[2])
210210
# one line in collection, seven otherwise
211-
get(io, :typeinfo, nothing) === nothing && (limit *= 7)
211+
if get(io, :typeinfo, nothing) === nothing
212+
limit *= 7
213+
else
214+
# strings in collections are typically indented one space
215+
limit -= 1
216+
end
212217
end
213218

214219
# early out for short strings

stdlib/REPL/src/REPL.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ function display(d::REPLDisplay, mime::MIME"text/plain", x)
510510
# this can override the :limit property set initially
511511
io = foldl(IOContext, d.repl.options.iocontext, init=io)
512512
end
513+
io = IOContext(io, :displaysize => displaysize(outstream(d.repl)))
513514
show_repl(io, mime, x[])
514515
println(io)
515516
end

test/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ end
897897
@test r == repr("x"^271) * " ⋯ 459 bytes ⋯ " * repr("x"^270)
898898
r = replstr(["x"^1000])
899899
@test length(r) < 120
900-
@test r == "1-element Vector{String}:\n " * repr("x"^31) * "939 bytes ⋯ " * repr("x"^30)
900+
@test r == "1-element Vector{String}:\n " * repr("x"^30) * "940 bytes ⋯ " * repr("x"^30)
901901
end
902902
end
903903

0 commit comments

Comments
 (0)