Format multi-line string contents #270
Open
+809
−174
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.
This PR adds support for formatting the interior contents of multi-line strings.
A setting has been added to control the behaviour (
format_multiline_strings
), and it defaults totrue
. I have enabled this by default because I'm confident in the initial implementation, and we should continue with our stated goal of "format the entire file".Before implementing this, I had to do some testing to confirm some of the fine-grained details.
My findings are asserted in this script, which can be summarised as
\r
is considered to end the line{$TEXTBLOCK}
directive, so it is safe to change themWith these findings, I implemented the normalisation as follows
With the interior of multiline strings be mutated, the cursor relocation was broken when inside such tokens. This has been fixed, and the new algorithm will maintain the number of line breaks relative to the end of the token as well as the number of bytes from the end of the relevant line.
Closes #238