Fix invalid indices when content is not long enough

Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
Marcel Müller 2026-03-09 15:20:07 +01:00
parent fa1582f3ad
commit 462355b6f2
4 changed files with 25 additions and 7 deletions

View file

@ -123,14 +123,16 @@ fn emit_ast_expr(
{
previous_post_whitespace_content = post_whitespace_content;
if let Some(ws) = prev_whitespace_content {
let idx = end_indices.last().copied();
eval.insert(
eval.len() - 2,
idx.unwrap_or(eval.len()),
Instruction::AppendContent {
content: ws.source().clone(),
},
);
let index_index = end_indices.len() - 1;
end_indices[index_index] += 1;
if let Some(idx) = end_indices.last_mut() {
*idx += 1;
}
}
if let TemplateAstExpr::IfConditional { expression } = &**expression {