Allow bare words to interpolate (#5327)

* Allow bare words to interpolate

* fix highlighting
This commit is contained in:
JT
2022-04-26 11:44:44 +12:00
committed by GitHub
parent 190f379ff3
commit 3492d4015d
3 changed files with 49 additions and 23 deletions

View File

@@ -326,23 +326,33 @@ pub fn flatten_expression(
output
}
Expr::StringInterpolation(exprs) => {
let mut output = vec![(
Span {
start: expr.span.start,
end: expr.span.start + 2,
},
FlatShape::StringInterpolation,
)];
let mut output = vec![];
for expr in exprs {
output.extend(flatten_expression(working_set, expr));
}
output.push((
Span {
start: expr.span.end - 1,
end: expr.span.end,
},
FlatShape::StringInterpolation,
));
if let Some(first) = output.first() {
if first.0.start != expr.span.start {
// If we aren't a bare word interpolation, also highlight the outer quotes
output.insert(
0,
(
Span {
start: expr.span.start,
end: expr.span.start + 2,
},
FlatShape::StringInterpolation,
),
);
output.push((
Span {
start: expr.span.end - 1,
end: expr.span.end,
},
FlatShape::StringInterpolation,
));
}
}
output
}
Expr::Record(list) => {