From 372a6bbca2fa0db4a2227ce117de07871abc80a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sat, 1 Jan 2022 18:58:22 +0100 Subject: [PATCH] fix: replace with parent separator on level pop in packet string builder --- Core/NosSmooth.Packets/PacketStringBuilder.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/NosSmooth.Packets/PacketStringBuilder.cs b/Core/NosSmooth.Packets/PacketStringBuilder.cs index fedcce9..d672ecd 100644 --- a/Core/NosSmooth.Packets/PacketStringBuilder.cs +++ b/Core/NosSmooth.Packets/PacketStringBuilder.cs @@ -96,14 +96,20 @@ public class PacketStringBuilder /// /// Pop the current level. /// + /// Whether to replace the last separator with the parent one. /// A result that may or may not have succeeded. There will be an error if the current level is the top one. - public Result PopLevel() + public Result PopLevel(bool replaceSeparator = true) { if (_currentLevel.Parent is null) { return new InvalidOperationError("The level cannot be popped, the stack is already at the top level."); } + if (replaceSeparator) + { + ReplaceWithParentSeparator(); + } + _currentLevel = _currentLevel.Parent; return Result.FromSuccess(); -- 2.49.0