Fix list spread syntax highlighting (#12793)

# Description
I broke syntax highlighting for list spreads in #12529. This should fix
#12792 😅. I just copied the code for highlighting record
spreads.
This commit is contained in:
Ian Manske 2024-05-07 05:41:47 +00:00 committed by GitHub
parent eccc558a4e
commit c54d223ea0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View File

@ -385,12 +385,23 @@ fn flatten_expression_into(
output.extend(flattened); output.extend(flattened);
} }
ListItem::Spread(_, expr) => { ListItem::Spread(op_span, expr) => {
output.push(( if op_span.start > last_end {
Span::new(expr.span.start, expr.span.start + 3), output.push((Span::new(last_end, op_span.start), FlatShape::List));
FlatShape::Operator, }
)); output.push((*op_span, FlatShape::Operator));
flatten_expression_into(working_set, expr, output); last_end = op_span.end;
let flattened_inner = flatten_expression(working_set, expr);
if let Some(first) = flattened_inner.first() {
if first.0.start > last_end {
output.push((Span::new(last_end, first.0.start), FlatShape::List));
}
}
if let Some(last) = flattened_inner.last() {
last_end = last.0.end;
}
output.extend(flattened_inner);
} }
} }
} }

View File

@ -3895,7 +3895,7 @@ pub fn parse_list_expression(
Type::List(elem_ty) => *elem_ty.clone(), Type::List(elem_ty) => *elem_ty.clone(),
_ => Type::Any, _ => Type::Any,
}; };
let span = Span::new(curr_span.start, spread_arg.span.end); let span = Span::new(curr_span.start, curr_span.start + 3);
(ListItem::Spread(span, spread_arg), elem_ty) (ListItem::Spread(span, spread_arg), elem_ty)
} else { } else {
let arg = parse_multispan_value( let arg = parse_multispan_value(