From 02b3f814c3c8237b100ecc60b3ad47c8f5da3d6e Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 27 Oct 2023 09:55:27 -0400 Subject: [PATCH 1/2] Remove use of length of Stateful Ref: https://github.com/JuliaLang/julia/pull/51747 --- src/stylemacro.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stylemacro.jl b/src/stylemacro.jl index 282ccec5..88cab65c 100644 --- a/src/stylemacro.jl +++ b/src/stylemacro.jl @@ -246,7 +246,8 @@ macro styled_str(raw_content::String) end expr, nextpos = Meta.parseatom(state.content, pos) nchars = length(state.content[pos:prevind(state.content, nextpos)]) - for _ in 1:min(length(state.s), nchars) + for _ in 1:nchars + isempty(state.s) && break popfirst!(state.s) end expr, nextpos From 508ab578b38ce171e589e492492d119ff45476b9 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 27 Oct 2023 09:59:21 -0400 Subject: [PATCH 2/2] Refactor zip of eachindex to just use pairs --- src/stylemacro.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stylemacro.jl b/src/stylemacro.jl index 88cab65c..fcd63cc8 100644 --- a/src/stylemacro.jl +++ b/src/stylemacro.jl @@ -110,8 +110,8 @@ macro styled_str(raw_content::String) # Instead we'll just use a `NamedTuple` state = let content = unescape_string(raw_content, ('{', '}', ':', '$', '\n', '\r')) - (; content, bytes = Vector{UInt8}(content), - s = Iterators.Stateful(zip(eachindex(content), content)), + (; content, bytes = Vector{UInt8}(content), + s = Iterators.Stateful(pairs(content)), parts = Any[], active_styles = Vector{Tuple{Int, Int, Union{Symbol, Expr, Pair{Symbol, Any}}}}[], pending_styles = Tuple{UnitRange{Int}, Union{Symbol, Expr, Pair{Symbol, Any}}}[],