Make axes labels length finder compatible with unicode runes

Signed-off-by: Xabier Larrakoetxea <slok69@gmail.com>
This commit is contained in:
Xabier Larrakoetxea 2019-05-03 07:15:49 +02:00
parent c1bf776dba
commit 36f116d9fc
No known key found for this signature in database
GPG Key ID: FDAD7FD8275E1B32
1 changed files with 3 additions and 1 deletions

View File

@ -18,6 +18,8 @@ package axes
import ( import (
"fmt" "fmt"
"image" "image"
"github.com/mum4k/termdash/internal/runewidth"
) )
const ( const (
@ -128,7 +130,7 @@ func NewYDetails(cvsAr image.Rectangle, yp *YProperties) (*YDetails, error) {
func longestLabel(labels []*Label) int { func longestLabel(labels []*Label) int {
var widest int var widest int
for _, label := range labels { for _, label := range labels {
if l := len(label.Value.Text()); l > widest { if l := runewidth.StringWidth(label.Value.Text()); l > widest {
widest = l widest = l
} }
} }