You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2021/05/03 11:43:38 UTC
[plc4x] 03/04: plc4go: fixed a bug in unwrap of AsciiBox where
boxes within boxes got wrongfully trimmed
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 5730d30a08264e4b06be30fffdbb674c9ac92276
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon May 3 13:42:10 2021 +0200
plc4go: fixed a bug in unwrap of AsciiBox where boxes within boxes got wrongfully trimmed
---
plc4go/internal/plc4go/spi/utils/asciiBox.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/plc4go/internal/plc4go/spi/utils/asciiBox.go b/plc4go/internal/plc4go/spi/utils/asciiBox.go
index 5b86899..7ddc2a3 100644
--- a/plc4go/internal/plc4go/spi/utils/asciiBox.go
+++ b/plc4go/internal/plc4go/spi/utils/asciiBox.go
@@ -308,7 +308,12 @@ func unwrap(box AsciiBox) AsciiBox {
}
runes := []rune(line)
// Strip the vertical Lines and trim the padding
- newLines[i-1] = strings.Trim(string(runes[1:len(runes)-1]), emptyPadding)
+ unwrappedLine := string(runes[1 : len(runes)-1])
+ if !strings.ContainsAny(unwrappedLine, verticalLine+horizontalLine) {
+ // only trim boxes witch don't contain other boxes
+ unwrappedLine = strings.Trim(unwrappedLine, emptyPadding)
+ }
+ newLines[i-1] = unwrappedLine
}
return AsciiBox(strings.Join(newLines, string(newLine)))
}