~ruther/NosSmooth

372a6bbca2fa0db4a2227ce117de07871abc80a6 — František Boháček 3 years ago 85d05d7
fix: replace with parent separator on level pop in packet string builder
1 files changed, 7 insertions(+), 1 deletions(-)

M Core/NosSmooth.Packets/PacketStringBuilder.cs
M Core/NosSmooth.Packets/PacketStringBuilder.cs => Core/NosSmooth.Packets/PacketStringBuilder.cs +7 -1
@@ 96,14 96,20 @@ public class PacketStringBuilder
    /// <summary>
    /// Pop the current level.
    /// </summary>
    /// <param name="replaceSeparator">Whether to replace the last separator with the parent one.</param>
    /// <returns>A result that may or may not have succeeded. There will be an error if the current level is the top one.</returns>
    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();

Do not follow this link