Skip to content

Commit 069a6d7

Browse files
IanButterworthKristofferC
authored andcommitted
Lock io within printpkgstyle to avoid print tearing (#4202)
(cherry picked from commit 895e9d3)
1 parent 0b4a3f1 commit 069a6d7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/utils.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
# "Precompiling" is the longest operation
2+
const pkgstyle_indent = textwidth(string(:Precompiling))
13

24
function printpkgstyle(io::IO, cmd::Symbol, text::String, ignore_indent::Bool=false; color=:green)
3-
indent = textwidth(string(:Precompiling)) # "Precompiling" is the longest operation
4-
ignore_indent && (indent = 0)
5-
printstyled(io, lpad(string(cmd), indent), color=color, bold=true)
6-
println(io, " ", text)
5+
indent = ignore_indent ? 0 : pkgstyle_indent
6+
@lock io begin
7+
printstyled(io, lpad(string(cmd), indent), color=color, bold=true)
8+
println(io, " ", text)
9+
end
710
end
811

912
function linewrap(str::String; io = stdout_f(), padding = 0, width = Base.displaysize(io)[2])

0 commit comments

Comments
 (0)