Skip to content

Commit

Permalink
fix: type instability in annotated string
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Oct 30, 2024
1 parent 80dce0d commit e84f6ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ProgressBars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ProgressBarsModule

using Compat: Fix
using ProgressMeter: Progress, next!
using StyledStrings: @styled_str
using StyledStrings: @styled_str, annotatedstring
using ..UtilsModule: AnnotatedString

# Simple wrapper for a progress bar which stores its own state
Expand Down Expand Up @@ -38,15 +38,15 @@ function format_for_meter((k, s), width::Integer)
new_s = if occursin('\n', s)
left_margin = length(" $(string(k)): ")
left_padding = ' '^(width - left_margin)
left_padding * newlines_to_spaces(s, width)
annotatedstring(left_padding, newlines_to_spaces(s, width))
else
s
end
return (k, new_s)
end

function newlines_to_spaces(s::AbstractString, width::Integer)
return join([rpad(line, width) for line in split(s, '\n')])
return join(rpad(line, width) for line in split(s, '\n'))
end

end

0 comments on commit e84f6ab

Please sign in to comment.