summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-12-05 21:59:42 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-12-05 22:00:42 +0900
commitf50272512016ce55e9a4ff33e8d46861ffcd11d3 (patch)
treee63e184c52b918ceb074eb7c4a5cae1420dbc3c7
parentb62a74b3156540cea4f12cf1d092cba77cb1db67 (diff)
Fix slice bound error on extremely narrow screen
-rw-r--r--src/terminal.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 83b3a7b5..4ddc6bae 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1116,6 +1116,7 @@ func (t *Terminal) displayWidthWithLimit(runes []rune, prefixWidth int, limit in
}
func (t *Terminal) trimLeft(runes []rune, width int) ([]rune, int32) {
+ width = util.Max(0, width)
var trimmed int32
// Assume that each rune takes at least one column on screen
if len(runes) > width {