Skip to content

Missing Substring Overload in v1 compat #64

@hexaeder

Description

@hexaeder

The following code works in Julia 1.11-beta

using StyledStrings: @styled_str
s = styled"{red:red},{green:green}"
subs = split(s, ',')[1]
lpad(subs, 10)

but errors unfortunately on v1.10 with the following error, it seems there is an overload missing.

ERROR: MethodError: no method matching SubString(::String, ::Int64, ::Int64, ::Val{:noshift})

Closest candidates are:
  SubString(::T, ::Int64, ::Int64) where T<:AbstractString
   @ Base strings/substring.jl:41
  SubString(::AbstractString, ::Integer, ::Integer)
   @ Base strings/substring.jl:42
  SubString(::SubString, ::Int64, ::Int64)
   @ Base strings/substring.jl:45
  ...

Stacktrace:
 [1] _ansi_writer(io::IOBuffer, s::SubString{…}, string_writer::typeof(write))
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:249
 [2] write(io::IOBuffer, s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}})
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:254
 [3] print(io::IOBuffer, s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}})
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:257
 [4] print_to_string(::String, ::Vararg{Any})
   @ Base ./strings/io.jl:148
 [5] string
   @ ./strings/io.jl:189 [inlined]
 [6] lpad(s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}}, n::Int64, p::Char)
   @ Base ./strings/util.jl:467
 [7] lpad(s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}}, n::Int64)
   @ Base ./strings/util.jl:462
 [8] top-level scope
   @ REPL[22]:1
 [9] top-level scope
   @ none:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions