Skip to content
Merged
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
2 changes: 2 additions & 0 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ function Base.showerror(io::IO, e::LimitIOException)
print(io, "$LimitIOException: aborted printing after attempting to print more than $(Base.format_bytes(e.maxbytes)) within a `LimitIO`.")
end

Base.displaysize(io::LimitIO) = _displaysize(io.io)

function Base.write(io::LimitIO, v::UInt8)
io.n > io.maxbytes && throw(LimitIOException(io.maxbytes))
n_bytes = write(io.io, v)
Expand Down
3 changes: 3 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,9 @@ end
@test output == "…[printing stopped after displaying 0 bytes; $hint]"
@test sprint(io -> show(REPL.LimitIO(io, 5), "abc")) == "\"abc\""
@test_throws REPL.LimitIOException(1) sprint(io -> show(REPL.LimitIO(io, 1), "abc"))

# displaying objects at the REPL sometimes needs access to displaysize, like Dict
@test displaysize(IOContext(REPL.LimitIO(stdout, 100), stdout)) == displaysize(stdout)
finally
REPL.SHOW_MAXIMUM_BYTES = previous
end
Expand Down