From 16ad3bc0423795e425865d988341fa7599348dbc Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 10 Sep 2021 12:55:00 +0800 Subject: [PATCH] Fix `MessageChainBuilder.copy` not copying caches --- .../src/commonMain/kotlin/message/data/MessageChainBuilder.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChainBuilder.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChainBuilder.kt index e31c452f5..e89c31305 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChainBuilder.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChainBuilder.kt @@ -186,7 +186,9 @@ public class MessageChainBuilder private constructor( * 将所有已有元素引用复制到一个新的 [MessageChainBuilder] */ public fun copy(): MessageChainBuilder { - return MessageChainBuilder(container.toMutableList()) + return MessageChainBuilder(container.toMutableList()).also { + it.cache.append(this.cache) + } } public override fun remove(element: SingleMessage): Boolean {