Skip to content

Commit

Permalink
Use LowerCaseOff in @show_name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fingolfin committed Sep 28, 2023
1 parent 5a115dd commit 1bd943d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Check warning on line 386 in src/AbstractAlgebra.jl

View check run for this annotation

Codecov / codecov/patch

src/AbstractAlgebra.jl#L385-L386

Added lines #L385 - L386 were not covered by tests
end
print(i, s)
return
end
Expand Down
5 changes: 4 additions & 1 deletion src/PrettyPrinting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 1511 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1509-L1511

Added lines #L1509 - L1511 were not covered by tests

indent_string!(io::IO, str::String) = (_unwrap(io).indent_str = str; io)

Expand Down

0 comments on commit 1bd943d

Please sign in to comment.