From 6226c3b0c86d65764b7218b76095bd21c4463361 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 6 Oct 2023 13:51:18 +0530 Subject: [PATCH] fix(common): prevent crashing when parsing comment trees Fixes COMPOSE-LOBSTERS-1Z --- .../kotlin/dev/msfjarvis/claw/common/comments/CommentNode.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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],