Skip to content

Commit 9b35f08

Browse files
committed
Merge branch 'jn/Statefulempty' [#21]
2 parents 41c8218 + 508ab57 commit 9b35f08

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/stylemacro.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ macro styled_str(raw_content::String)
110110

111111
# Instead we'll just use a `NamedTuple`
112112
state = let content = unescape_string(raw_content, ('{', '}', ':', '$', '\n', '\r'))
113-
(; content, bytes = Vector{UInt8}(content),
114-
s = Iterators.Stateful(zip(eachindex(content), content)),
113+
(; content, bytes = Vector{UInt8}(content),
114+
s = Iterators.Stateful(pairs(content)),
115115
parts = Any[],
116116
active_styles = Vector{Tuple{Int, Int, Union{Symbol, Expr, Pair{Symbol, Any}}}}[],
117117
pending_styles = Tuple{UnitRange{Int}, Union{Symbol, Expr, Pair{Symbol, Any}}}[],
@@ -246,7 +246,8 @@ macro styled_str(raw_content::String)
246246
end
247247
expr, nextpos = Meta.parseatom(state.content, pos)
248248
nchars = length(state.content[pos:prevind(state.content, nextpos)])
249-
for _ in 1:min(length(state.s), nchars)
249+
for _ in 1:nchars
250+
isempty(state.s) && break
250251
popfirst!(state.s)
251252
end
252253
expr, nextpos

0 commit comments

Comments
 (0)