mirror of
https://github.com/nushell/nushell.git
synced 2024-11-08 01:24:38 +01:00
Improve escaping in string interpolation (#4982)
This commit is contained in:
parent
3484e0defd
commit
cf88c8eef3
@ -1438,7 +1438,14 @@ pub fn parse_string_interpolation(
|
|||||||
|
|
||||||
#[allow(clippy::needless_range_loop)]
|
#[allow(clippy::needless_range_loop)]
|
||||||
while b != end {
|
while b != end {
|
||||||
if contents[b - start] == b'(' && mode == InterpolationMode::String {
|
if contents[b - start] == b'('
|
||||||
|
&& (if double_quote && (b - start) > 0 {
|
||||||
|
contents[b - start - 1] != b'\\'
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
})
|
||||||
|
&& mode == InterpolationMode::String
|
||||||
|
{
|
||||||
mode = InterpolationMode::Expression;
|
mode = InterpolationMode::Expression;
|
||||||
if token_start < b {
|
if token_start < b {
|
||||||
let span = Span {
|
let span = Span {
|
||||||
|
@ -345,6 +345,11 @@ fn string_escape_interpolation() -> TestResult {
|
|||||||
run_test(r#"$"\u015B(char hamburger)abc""#, "ś≡abc")
|
run_test(r#"$"\u015B(char hamburger)abc""#, "ś≡abc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn string_escape_interpolation2() -> TestResult {
|
||||||
|
run_test(r#"$"2 + 2 is \(2 + 2)""#, "2 + 2 is (2 + 2)")
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn proper_rest_types() -> TestResult {
|
fn proper_rest_types() -> TestResult {
|
||||||
run_test(
|
run_test(
|
||||||
|
Loading…
Reference in New Issue
Block a user