Preserve significant trailing space in UseTextBlocks (#1132)#1133
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the last (or only) piece of content in a concatenation ends with a significant trailing space and no newline,
UseTextBlocksplaced the closing"""on the same line as that content:A text block strips trailing whitespace from every line before escape processing, so the space before the closing delimiter is removed. The runtime value silently changed from
...Transfer id:to...Transfer id:— no exception, compiles fine, easy to miss.The recipe already handled trailing spaces before a newline via the
\n→\s\nreplacement, but the trailing space on the final line (no following newline) fell through.Fix
When the joined content ends with a space, escape that trailing space as
\s(which is interpreted after whitespace stripping) and add a\line continuation so the closing delimiter sits on its own line without introducing a spurious trailing newline:This produces a value byte-for-byte identical to the original.
Tests
preserveTrailingSpaceOnLastLinereproducing the issue.preserveTrailingWhiteSpacestest, which previously asserted the buggyWHERE something = 1; """output that dropped the trailing space.