Skip to content

Commit 4e05f00

Browse files
tecosaurKristofferC
authored andcommitted
Apply an inference barrier to annot printstyled (#59596)
In 6d78a4a we introduced an inference barrier to the various AnnotatedX/StyledStrings methods whose implementations are frustratingly split between Base and a Stdlib, to ease the pain of invalidations. As has recently been pointed out in the re-opened #57997, this missed a `printstyled` method. We address that here, together with a tweak to the StyledStrings library. Reported-by: Neven Sajko <[email protected]> (cherry picked from commit 406d37b)
1 parent 64f2dca commit 4e05f00

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

base/strings/annotated_io.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ function _insert_annotations!(io::AnnotatedIOBuffer, annotations::Vector{RegionA
200200
end
201201
end
202202

203+
function printstyled end
204+
203205
# NOTE: This is an interim solution to the invalidations caused
204206
# by the split styled display implementation. This should be
205207
# replaced by a more robust solution (such as a consolidation of
@@ -250,6 +252,14 @@ Base.print(io::AnnotatedIOBuffer, s::Union{<:AnnotatedString, SubString{<:Annota
250252
Base.print(io::AnnotatedIOBuffer, c::AnnotatedChar) =
251253
(write(io, c); nothing)
252254

255+
styled_print(io::AnnotatedIOBuffer, msg::Any, kwargs::Any) = print(io, msg...)
256+
257+
styled_print_(io::AnnotatedIOBuffer, @nospecialize(msg), @nospecialize(kwargs)) =
258+
invoke_in_world(tls_world_age(), styled_print, io, msg, kwargs)::Nothing
259+
260+
Base.printstyled(io::AnnotatedIOBuffer, msg...; kwargs...) =
261+
styled_print_(io, msg, kwargs)
262+
253263
# Escape
254264

255265
Base.escape_string(io::IO, s::Union{<:AnnotatedString, SubString{<:AnnotatedString}},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ad2e6ba06c98990865f808b26b8f148c
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24e530c095f7838380adeb6f45349cf776df524a2fc721eb8b11411d25bc132a58c1048a89d630ba1ee66bf9a52cce9a0fbe2b4a76c33b11160c00ecb7a919a1

stdlib/StyledStrings.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
STYLEDSTRINGS_BRANCH = main
2-
STYLEDSTRINGS_SHA1 = 3fe829fcf611b5fefaefb64df7e61f2ae82db117
2+
STYLEDSTRINGS_SHA1 = 68bf7b1f83f334391dc05fda34f48267e04e2bd0
33
STYLEDSTRINGS_GIT_URL := https://github.com/JuliaLang/StyledStrings.jl.git
44
STYLEDSTRINGS_TAR_URL = https://api.github.com/repos/JuliaLang/StyledStrings.jl/tarball/$1

0 commit comments

Comments
 (0)