Skip to content

Commit d39d1c3

Browse files
committed
shorten leaf printing
1 parent 17102dc commit d39d1c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/interface.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ onevalue(λ, x::AbstractArray{T}) where T = onevalue(convert(float(T), λ), x)
120120

121121
function Base.show(io::IO, ℓ::Leaf) # show method is mostly to hide its long type!
122122
ioc = IOContext(io, :compact => true)
123-
print(ioc, "Leaf(", ℓ.rule, ", ")
124-
show(ioc, ℓ.state)
125-
print(io, ")")
123+
printstyled(io, "Leaf("; color = :green)
124+
show(ioc, ℓ.rule)
125+
printstyled(", "; color = :green)
126+
str = sprint(show, ℓ.state; context = ioc)
127+
print(io, length(str) < 70 ? str : first(str, 50) * "")
128+
printstyled(io, ")"; color = :green)
126129
end
127130

0 commit comments

Comments
 (0)