Skip to content

Commit 88fadc7

Browse files
committed
Improve comment
1 parent b1b0e83 commit 88fadc7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Sources/SwiftBasicFormat/BasicFormat.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,15 @@ open class BasicFormat: SyntaxRewriter {
413413
anchorPoints[token] = currentIndentationLevel
414414
}
415415

416-
// Add an indentation in the line for the initial token,
417-
// if the token is present and its leadingTrivia does not contain the indentation.
416+
// If we are formatting a subtree and the line that the initial token occurs on is indented,
417+
// use that line indentation for the first token in the subtree to format.
418+
// For example, when formatting only the code block in the following,
419+
// then the opening `{` should be indented by four spaces.
420+
// ```
421+
// func test() {
422+
// print(1)
423+
// }
424+
// ``
418425
if isInitialToken && token.presence == .present {
419426
let indentationOfLine = token.indentationOfLine
420427
if token.leadingTrivia.pieces.suffix(indentationOfLine.pieces.count) != indentationOfLine.pieces {

0 commit comments

Comments
 (0)