From 1bd943dd9317248dcfd5199941d33be8f6df7e73 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 28 Sep 2023 11:47:52 +0200 Subject: [PATCH] Use LowerCaseOff in @show_name If we print a name, we don't want to change its capitalization. I don't have a good test case here, but it fixes this bug in Oscar: julia> F = cyclotomic_field(3)[1]; julia> vector_space(Fun, 6) Vector space of dimension 6 over f In addition, teach PrettyPrinting code to work through multiple `IOContext` layers. --- src/AbstractAlgebra.jl | 6 ++++-- src/PrettyPrinting.jl | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/AbstractAlgebra.jl b/src/AbstractAlgebra.jl index 3517fee901..d12f563436 100644 --- a/src/AbstractAlgebra.jl +++ b/src/AbstractAlgebra.jl @@ -381,8 +381,10 @@ macro show_name(io, O) set_name!(o, s) end end - if get(i, :compact, false) && - s !== nothing + if get(i, :compact, false) && s !== nothing + if AbstractAlgebra.PrettyPrinting._supports_io_custom(i) + print(i, LowercaseOff()) + end print(i, s) return end diff --git a/src/PrettyPrinting.jl b/src/PrettyPrinting.jl index 685885ffeb..840edf9bae 100644 --- a/src/PrettyPrinting.jl +++ b/src/PrettyPrinting.jl @@ -1504,8 +1504,11 @@ mutable struct IOCustom{IO_t <: IO} <: Base.AbstractPipe end _unwrap(io::IOCustom) = io +_unwrap(io::IOContext) = _unwrap(io.io) -_unwrap(io::IOContext) = io.io +_supports_io_custom(io::IOCustom) = true +_supports_io_custom(io::IOContext) = _supports_io_custom(io.io) +_supports_io_custom(io::Any) = false indent_string!(io::IO, str::String) = (_unwrap(io).indent_str = str; io)