Skip to content

Commit

Permalink
fix(rsx): zero-lengthed source with non-empty segments is non-trivial
Browse files Browse the repository at this point in the history
  • Loading branch information
sehnryr committed Feb 8, 2025
1 parent b5038bc commit a48fe00
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/rsx/src/ifmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ impl IfmtInput {
}

fn is_simple_expr(&self) -> bool {
// If there are segments but the source span has zero length, it's not a simple expression.
if !self.segments.is_empty() && self.source.span().byte_range().len() == 0 {
return false;
}

self.segments.iter().all(|seg| match seg {
Segment::Literal(_) => true,
Segment::Formatted(FormattedSegment { segment, .. }) => {
Expand Down

0 comments on commit a48fe00

Please sign in to comment.