Skip to content

Commit cf73295

Browse files
fix: preserve IOContext for printing (#322)
* fix: preserve IOContext for printing * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent fe5c581 commit cf73295

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ConcreteRArray.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ function Base.show(io::IO, X::ConcreteRScalar{T}) where {T}
184184
println(io, "<Empty buffer>")
185185
return nothing
186186
end
187-
str = sprint(show, to_number(X))
188-
return print(io, "$(typeof(X))($(str))")
187+
print(io, "$(typeof(X))(")
188+
show(io, to_number(X))
189+
print(io, ")")
190+
return nothing
189191
end
190192

191193
function Base.print_array(io::IO, X::ConcreteRArray)
@@ -201,8 +203,10 @@ function Base.show(io::IO, X::ConcreteRArray)
201203
println(io, "<Empty buffer>")
202204
return nothing
203205
end
204-
str = sprint(show, convert(Array, X))
205-
return print(io, "$(typeof(X))($(str))")
206+
print(io, "$(typeof(X))(")
207+
show(io, convert(Array, X))
208+
print(io, ")")
209+
return nothing
206210
end
207211

208212
function Base.getindex(a::ConcreteRArray{T}, args::Vararg{Int,N}) where {T,N}

0 commit comments

Comments
 (0)