diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt index a396181e..33869720 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt @@ -25,7 +25,7 @@ internal data class CommentNode( child.parent = this } else { child.indentLevel += 1 - children.last().addChild(child) + children.lastOrNull()?.addChild(child) } } } @@ -47,7 +47,7 @@ internal fun createListNode( ) ) } else { - commentNodes.last().let { + commentNodes.lastOrNull()?.let { it.addChild( CommentNode( comment = comments[i],