Skip to content

Commit eb348e5

Browse files
committed
Format
1 parent 838485c commit eb348e5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Sources/SwiftBasicFormat/Indenter.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ private class Indenter: SyntaxRewriter {
8787
// newline here is before the start of the trailing trivia (since
8888
// it is part of the string’s value)
8989
if case .stringSegment(let content) = token.tokenKind,
90-
let last = content.last,
91-
last.isNewline {
90+
let last = content.last,
91+
last.isNewline
92+
{
9293
shouldIndent = true
9394
}
9495

95-
return token
96+
return
97+
token
9698
.with(\.leadingTrivia, indentedLeadingTrivia)
9799
// source files as parsed can’t have anything requiring indentation
98100
// here, but it’s easy to do `.with(\.trailingTrivia, .newline)` so

Tests/SwiftBasicFormatTest/IndentTests.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ fileprivate func assertIndented(
2525
file: StaticString = #filePath,
2626
line: UInt = #line
2727
) {
28-
assertStringsEqualWithDiff(Parser.parse(source: source).indented(by: indentation, indentFirstLine: indentFirstLine).description, expected, file: file, line: line)
28+
assertStringsEqualWithDiff(
29+
Parser.parse(source: source).indented(by: indentation, indentFirstLine: indentFirstLine).description,
30+
expected,
31+
file: file,
32+
line: line
33+
)
2934
}
3035

3136
final class IndentTests: XCTestCase {

0 commit comments

Comments
 (0)