Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Aug 24, 2024
1 parent 338454a commit 4cc2f41
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/strings/io.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

function _join_preserve_annotations(iterator, args...)
if _isannotated(eltype(iterator)) || any(_isannotated, args)
if isconcretetype(eltype(iterator)) && !_isannotated(eltype(iterator)) && !any(_isannotated, args)
sprint(join, iterator, args...)
else
io = AnnotatedIOBuffer()
join(io, iterator, args...)
read(seekstart(io), AnnotatedString{String})
else
sprint(join, iterator, args...)
# If we know (from compile time information, or dynamically in the case
# of iterators with a non-concrete eltype), that the result is annotated
# in nature, we extract an `AnnotatedString`, otherwise we just extract
# a plain `String` from `io`.
if isconcretetype(eltype(iterator)) || !isempty(io.annotations)
read(seekstart(io), AnnotatedString{String})
else
String(take!(io.io))
end
end
end

Expand Down

0 comments on commit 4cc2f41

Please sign in to comment.