Skip to content

Commit 26b5d2f

Browse files
committed
Fix invalid non-empty state assumptions in macro
In the expansion, it's assumed that there is at least one charater after an escaped character, but this is not always the case.
1 parent 0625bce commit 26b5d2f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/stylemacro.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ macro styled_str(raw_content::String)
215215
if char in ('{', '}', '$', '\\')
216216
deleteat!(state.bytes, i + state.offset[] - 1)
217217
state.offset[] -= ncodeunits('\\')
218-
elseif char ('\n', '\r')
218+
elseif char ('\n', '\r') && !isempty(state.s)
219219
skipped = 0
220220
if char == '\r' && last(peek(state.s)) == '\n'
221221
popfirst!(state.s)
222222
skipped += 1
223223
end
224-
while last(peek(state.s)) (' ', '\t')
224+
while !isempty(state.s) && last(peek(state.s)) (' ', '\t')
225225
popfirst!(state.s)
226226
skipped += 1
227227
end

0 commit comments

Comments
 (0)