Skip to content

Commit

Permalink
Adjust to changed annotations function return form
Browse files Browse the repository at this point in the history
For consistency, calling `annotations` on an AnnotatedString, whether an
index or range is specified, now always returns a vector of
region-annotation tuples.

Previously, when an index was specified, only the annotations would be
returned. Thus, code that relies on this previous behaviour must now
apply `last` to each element of the returned vector.
  • Loading branch information
tecosaur committed Feb 11, 2024
1 parent 7ce4e69 commit e0ca0f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/faces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ getface() = FACES.current[][:default]
Get the merged [`Face`](@ref) that applies to `s` at index `i`.
"""
getface(s::AnnotatedString, i::Integer) =
getface(annotations(s, i))
getface(map(last, annotations(s, i)))

"""
getface(c::AnnotatedChar)
Expand Down
4 changes: 2 additions & 2 deletions src/regioniterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ function eachregion(s::AnnotatedString, region::UnitRange{Int}=firstindex(s):las
for region in first.(s.annotations)) |>
unique |> sort)
isempty(changepoints) &&
return RegionIterator(s.string, [region], [annotations(s, first(region))])
return RegionIterator(s.string, [region], [map(last, annotations(s, first(region)))])
function registerchange!(start, stop)
push!(regions, start:stop)
push!(annots, annotations(s, start))
push!(annots, map(last, annotations(s, start)))
end
if first(region) < first(changepoints)
registerchange!(first(region), prevind(s, first(changepoints)))
Expand Down

0 comments on commit e0ca0f8

Please sign in to comment.