From 1372edd896d113312c53b5b9811909527d8b8254 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Thu, 17 Feb 2022 00:23:04 -0500 Subject: [PATCH] feat: nicer string interpolation --- src/rules/string.rs | 2 ++ tests/cases/string/in | 10 ++++++++++ tests/cases/string/out | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/src/rules/string.rs b/src/rules/string.rs index 44951ab..3e094ef 100644 --- a/src/rules/string.rs +++ b/src/rules/string.rs @@ -141,9 +141,11 @@ pub fn rule( )); if index + 1 != portions.len() { + steps.push_back(crate::builder::Step::Indent); steps.push_back(crate::builder::Step::FormatWider( interpolations.next().unwrap().clone(), )); + steps.push_back(crate::builder::Step::Dedent); } } } diff --git a/tests/cases/string/in b/tests/cases/string/in index 3f094e7..5d5fc8f 100644 --- a/tests/cases/string/in +++ b/tests/cases/string/in @@ -78,4 +78,14 @@ ${ expr "" v } '' + + '' + --${ + "test" + } + '' + + "--${ + "test" + }" ] diff --git a/tests/cases/string/out b/tests/cases/string/out index c858487..e1bfe23 100644 --- a/tests/cases/string/out +++ b/tests/cases/string/out @@ -78,4 +78,14 @@ ${expr "" v} '' + + '' + --${ + "test" + } + '' + + "--${ + "test" + }" ]