Skip to content

Commit 76969b2

Browse files
Copilotjakebailey
andcommitted
Refactor nil check logic per code review feedback
Simplified the listIndentsChild computation by moving it inside the nil check, avoiding redundant nil check and limiting listLine scope. Co-authored-by: jakebailey <[email protected]>
1 parent 9f74d75 commit 76969b2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/format/indent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ func getIndentationForNodeWorker(
6666
// }, { itself contributes nothing.
6767
// prop: 1 L3 - The indentation of the second object literal is best understood by
6868
// }) looking at the relationship between the list and *first* list item.
69-
var listLine int
69+
var listIndentsChild bool
7070
if firstListChild != nil {
71-
listLine, _ = getStartLineAndCharacterForNode(firstListChild, sourceFile)
71+
listLine, _ := getStartLineAndCharacterForNode(firstListChild, sourceFile)
72+
listIndentsChild = listLine > containingListOrParentStartLine
7273
}
73-
listIndentsChild := firstListChild != nil && listLine > containingListOrParentStartLine
7474
actualIndentation := getActualIndentationForListItem(current, sourceFile, options, listIndentsChild)
7575
if actualIndentation != -1 {
7676
return actualIndentation + indentationDelta

0 commit comments

Comments
 (0)