Check bounds on LastVisualX

Fixes #708
This commit is contained in:
Zachary Yedidia
2017-06-18 15:38:33 -04:00
parent 39b5c4746e
commit 3741a71cc5

View File

@@ -337,6 +337,9 @@ func (c *Cursor) GetCharPosInLine(lineNum, visualPos int) int {
func (c *Cursor) GetVisualX() int {
runes := []rune(c.buf.Line(c.Y))
tabSize := int(c.buf.Settings["tabsize"].(float64))
if c.X > len(runes) {
c.X = len(runes) - 1
}
return StringWidth(string(runes[:c.X]), tabSize)
}