Fix indentation of multiline raw string literals with --indent-strings#2484
Merged
Fix indentation of multiline raw string literals with --indent-strings#2484
--indent-strings#2484Conversation
…\", ##\"\"\") Agent-Logs-Url: https://github.com/nicklockwood/SwiftFormat/sessions/b3e76418-d5c0-488a-a363-64893ef5d5d3 Co-authored-by: calda <1811727+calda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix indentation issue for multiline strings with hash marks
Fix indentation of multiline raw string literals with Mar 30, 2026
--indent-strings
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2484 +/- ##
===========================================
- Coverage 95.30% 95.29% -0.01%
===========================================
Files 167 167
Lines 25346 25349 +3
===========================================
+ Hits 24156 24157 +1
- Misses 1190 1192 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
calda
approved these changes
Mar 30, 2026
calda
added a commit
that referenced
this pull request
Apr 11, 2026
…gs` (#2484) Co-authored-by: calda <1811727+calda@users.noreply.github.com>
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.
The
indentStringsoption was silently ignored for raw multiline string literals (#"""..."""#,##"""..."""##), always stripping their content indentation regardless of the setting.Root cause: The
indentStringspost-processing block matched only.startOfScope("\"\"\"")— the exact plain-"""token — missing raw variants like#""",##""", etc.Fix:
forEach(.startOfScope("\"\"\""))withforEachToken(where:)matching any multiline string start-of-scope that contains"— this covers all hash-prefixed string delimiters while correctly excluding multiline regex literals (#/.../#, which also satisfyisMultilineStringDelimiter)Tests added (mirroring existing
indentStringscoverage for non-raw strings):indentStrings: trueinside a method with#"""#"""is on its own line (omitted return)#"""##"""..."""##