Skip to content

Commit

Permalink
Add missing _unwrap call in Dedent handler
Browse files Browse the repository at this point in the history
Also clarify write_indent code, it is always called on an IOCustom instance
  • Loading branch information
fingolfin committed Sep 19, 2023
1 parent f23ced5 commit ab904a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/PrettyPrinting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1535,14 +1535,14 @@ Base.displaysize(io::IOCustom) = displaysize(io.io)

write(io::IO, ::Indent) = (_unwrap(io).indent_level += 1; nothing)
print(io::IO, ::Indent) = write(io, Indent())
write(io::IO, ::Dedent) = (_unwrap(io).indent_level = max(0, io.indent_level - 1); nothing)
write(io::IO, ::Dedent) = (_unwrap(io).indent_level = max(0, _unwrap(io).indent_level - 1); nothing)
print(io::IO, ::Dedent) = write(io, Dedent())
write(io::IO, ::Lowercase) = (_unwrap(io).lowercasefirst = true; nothing)
print(io::IO, ::Lowercase) = write(io, Lowercase())
write(io::IO, ::LowercaseOff) = (_unwrap(io).lowercasefirst = false; nothing)
print(io::IO, ::LowercaseOff) = write(io, LowercaseOff())

write_indent(io::IO) = write(_unwrap(io).io, io.indent_str^io.indent_level)
write_indent(io::IOCustom) = write(io.io, io.indent_str^io.indent_level)

write(io::IOCustom, chr::Char) = write(io, string(chr)) # Need to catch writing a '\n'

Expand Down

0 comments on commit ab904a0

Please sign in to comment.