From e0ca0f85412ea5cafabfeaaec4d62ca26c3959d2 Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 11 Feb 2024 18:41:31 +0800 Subject: [PATCH] Adjust to changed annotations function return form 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. --- src/faces.jl | 2 +- src/regioniterator.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/faces.jl b/src/faces.jl index 27dfdba6..097b8e9d 100644 --- a/src/faces.jl +++ b/src/faces.jl @@ -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) diff --git a/src/regioniterator.jl b/src/regioniterator.jl index cdf23238..ded3987d 100644 --- a/src/regioniterator.jl +++ b/src/regioniterator.jl @@ -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)))