File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
main/java/software/amazon/smithy/utils
test/java/software/amazon/smithy/utils Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -650,11 +650,11 @@ public CodeWriter popState() {
650650 // back into a parent state.
651651 popped .builder .setLength (0 );
652652 popped .builder .append (result );
653- } else {
653+ } else if (! result . isEmpty ()) {
654654 // Sections can be added that are just placeholders. In those cases,
655655 // do not write anything unless the section emitted a non-empty string.
656- // Note that this has already been formatted, so escape "$" .
657- writeOptional (result . replace ( "$" , "$$" ) );
656+ // This has already been formatted, so writeWithNoFormatting is used .
657+ writeWithNoFormatting (result );
658658 }
659659 }
660660
Original file line number Diff line number Diff line change @@ -538,6 +538,21 @@ public void poppedSectionsEscapeDollars() {
538538 assertThat (result , equalTo ("$Hello\n " ));
539539 }
540540
541+ @ Test
542+ public void poppedSectionsEscapeCustomExpressionStarts () {
543+ CodeWriter writer = CodeWriter .createDefault ();
544+ String result = writer
545+ .setExpressionStart ('#' )
546+ .pushState ("foo" )
547+ .write ("##Hello" )
548+ .write ("$Hello" )
549+ .write ("$$Hello" )
550+ .popState ()
551+ .toString ();
552+
553+ assertThat (result , equalTo ("#Hello\n $Hello\n $$Hello\n " ));
554+ }
555+
541556 @ Test
542557 public void canWriteInline () {
543558 String result = CodeWriter .createDefault ()
You can’t perform that action at this time.
0 commit comments