aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/text.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-05-10 00:45:36 +0200
committerMichael Muré <batolettre@gmail.com>2019-05-10 00:45:36 +0200
commit606a66dd6d60f46807735e2e98d080f570229e61 (patch)
tree22b75681acb04af724eeae58e1989732309150f5 /util/text/text.go
parent239646f3ef7716097f3b2f5f331f972e3afd06ae (diff)
downloadgit-bug-606a66dd6d60f46807735e2e98d080f570229e61.tar.gz
text: fix escape sequence disapearing at the end of a line
Diffstat (limited to 'util/text/text.go')
-rw-r--r--util/text/text.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/text/text.go b/util/text/text.go
index 87db8c30..39584d5d 100644
--- a/util/text/text.go
+++ b/util/text/text.go
@@ -60,7 +60,7 @@ func WrapLeftPadded(text string, lineWidth int, leftPad int) (string, int) {
// WRAPPING ALGORITHM: The line is broken into non-breakable chunks, then line
// breaks ("\n") are inserted between these groups so that the total length
// between breaks does not exceed the required width. Words that are longer than
-// the textWidth are broen into pieces no longer than textWidth.
+// the textWidth are broken into pieces no longer than textWidth.
//
func softwrapLine(line string, textWidth int) string {
// NOTE: terminal escapes are stripped out of the line so the algorithm is
@@ -187,6 +187,11 @@ func applyTermEscapes(line string, escapes []escapeItem) string {
}
}
+ // Don't forget the trailing escape, if any.
+ if currItem == len(escapes)-1 && currPos == escapes[currItem].pos {
+ out += escapes[currItem].item
+ }
+
return out
}