Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/strings/annotated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ function _insert_annotations!(io::AnnotatedIOBuffer, annotations::Vector{Tuple{U
for i in reverse(axes(annotations, 1))
annot = annotations[i]
first(first(annot)) == 1 || continue
i <= length(io.annotations) || continue
if last(annot) == last(last(io.annotations))
valid_run = true
for runlen in 1:i
Expand Down
6 changes: 6 additions & 0 deletions test/strings/annotated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ end
@test write(aio2, Base.AnnotatedChar('c', [:b => 2, :c => 3, :d => 4])) == 1
@test Base.annotations(aio2) == [(1:2, :a => 1), (1:3, :b => 2), (3:3, :c => 3), (3:3, :d => 4)]
end
let aio2 = Base.AnnotatedIOBuffer()
@test write(aio2, Base.AnnotatedChar('a', [:b => 1])) == 1
@test write(aio2, Base.AnnotatedChar('b', [:a => 1, :b => 1])) == 1
@test read(seekstart(aio2), Base.AnnotatedString) ==
Base.AnnotatedString("ab", [(1:1, :b => 1), (2:2, :a => 1), (2:2, :b => 1)])
end
# Working through an IOContext
aio = Base.AnnotatedIOBuffer()
wrapio = IOContext(aio)
Expand Down