Skip to content

Commit

Permalink
Revert "More consistent return value for annotations" (#53309)
Browse files Browse the repository at this point in the history
Reverts #53281 as it appears to have broken CI on all
subsequent commits:
#53281 (comment)

According to the CI logs, it is this test that aborts early on in the
rr-trace log:
```
Pkg.test(TEST_PKG.name; coverage = coverage_path)
```
  • Loading branch information
vtjnash authored Feb 13, 2024
1 parent d211398 commit 81c3474
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions base/strings/annotated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ lastindex(s::AnnotatedString) = lastindex(s.string)
function getindex(s::AnnotatedString, i::Integer)
@boundscheck checkbounds(s, i)
@inbounds if isvalid(s, i)
AnnotatedChar(s.string[i], map(last, annotations(s, i)))
AnnotatedChar(s.string[i], annotations(s, i))
else
string_index_err(s, i)
end
Expand Down Expand Up @@ -354,16 +354,12 @@ annotate!(c::AnnotatedChar, @nospecialize(labelval::Pair{Symbol, <:Any})) =
(push!(c.annotations, labelval); c)

"""
annotations(str::Union{AnnotatedString, SubString{AnnotatedString}},
[position::Union{Integer, UnitRange}]) ->
Vector{Tuple{UnitRange{Int}, Pair{Symbol, Any}}}
annotations(str::AnnotatedString, [position::Union{Integer, UnitRange}])
annotations(str::SubString{AnnotatedString}, [position::Union{Integer, UnitRange}])
Get all annotations that apply to `str`. Should `position` be provided, only
annotations that overlap with `position` will be returned.
Annotations are provided together with the regions they apply to, in the form of
a vector of region–annotation tuples.
See also: `annotate!`.
"""
annotations(s::AnnotatedString) = s.annotations
Expand All @@ -373,22 +369,22 @@ annotations(s::SubString{<:AnnotatedString}) =

function annotations(s::AnnotatedString, pos::UnitRange{<:Integer})
# TODO optimise
filter(label -> !isempty(intersect(pos, first(label))),
s.annotations)
annots = filter(label -> !isempty(intersect(pos, first(label))),
s.annotations)
last.(annots)
end

annotations(s::AnnotatedString, pos::Integer) = annotations(s, pos:pos)

annotations(s::SubString{<:AnnotatedString}, pos::Integer) =
annotations(s.string, s.offset + pos)

annotations(s::SubString{<:AnnotatedString}, pos::UnitRange{<:Integer}) =
annotations(s.string, first(pos)+s.offset:last(pos)+s.offset)

"""
annotations(chr::AnnotatedChar) -> Vector{Pair{Symbol, Any}}
annotations(chr::AnnotatedChar)
Get all annotations of `chr`, in the form of a vector of annotation pairs.
Get all annotations of `chr`.
"""
annotations(c::AnnotatedChar) = c.annotations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c1fd1bb7e3f9ab00afe0758a8a101374
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
373302f1d32a5b5ad0efacf14fa82a16fd877c11ca589fc1f1492eb1d4bcd0f49a2a5a3f471f8577649309c8a03634e7467e31b403cfd6ab8a8e4a775d7f4e53

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion stdlib/StyledStrings.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
STYLEDSTRINGS_BRANCH = main
STYLEDSTRINGS_SHA1 = e0ca0f85412ea5cafabfeaaec4d62ca26c3959d2
STYLEDSTRINGS_SHA1 = a1b2ae2434cd7d8199fa8647339422fe0e1d0324
STYLEDSTRINGS_GIT_URL := https://github.com/JuliaLang/StyledStrings.jl.git
STYLEDSTRINGS_TAR_URL = https://api.github.com/repos/JuliaLang/StyledStrings.jl/tarball/$1

0 comments on commit 81c3474

Please sign in to comment.