From 3b49e1a2b6ee12e8419363c7b9fbd5f9c98f89bb Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Sun, 19 Jul 2020 21:28:06 +0300 Subject: [PATCH] Add check for truncatechar (#420) * Add check for truncatechar When value is longer than 1 character, it throws an error * Use runeSliceWidth instead of len --- eval.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eval.go b/eval.go index 6a0957c..ec30b2e 100644 --- a/eval.go +++ b/eval.go @@ -315,6 +315,11 @@ func (e *setExpr) eval(app *app, args []string) { case "timefmt": gOpts.timefmt = e.val case "truncatechar": + if runeSliceWidth([]rune(e.val)) > 1 { + app.ui.echoerr("truncatechar: value should be 1 character long") + return + } + gOpts.truncatechar = e.val default: app.ui.echoerrf("unknown option: %s", e.opt)