Skip to content

Commit

Permalink
Fix invalid non-empty state assumptions in macro
Browse files Browse the repository at this point in the history
In the expansion, it's assumed that there is at least one charater after
an escaped character, but this is not always the case.
  • Loading branch information
tecosaur committed Feb 10, 2024
1 parent 0625bce commit 26b5d2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stylemacro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ macro styled_str(raw_content::String)
if char in ('{', '}', '$', '\\')
deleteat!(state.bytes, i + state.offset[] - 1)
state.offset[] -= ncodeunits('\\')
elseif char ('\n', '\r')
elseif char ('\n', '\r') && !isempty(state.s)
skipped = 0
if char == '\r' && last(peek(state.s)) == '\n'
popfirst!(state.s)
skipped += 1
end
while last(peek(state.s)) (' ', '\t')
while !isempty(state.s) && last(peek(state.s)) (' ', '\t')
popfirst!(state.s)
skipped += 1
end
Expand Down

0 comments on commit 26b5d2f

Please sign in to comment.