Store visual x when cursor loc moves in certain cases

Fixes #739
This commit is contained in:
Zachary Yedidia
2017-07-15 17:52:56 -04:00
parent 18ad74a982
commit 3b2d7abe3d
2 changed files with 11 additions and 0 deletions

View File

@@ -350,6 +350,11 @@ func (c *Cursor) GetVisualX() int {
return StringWidth(string(runes[:c.X]), tabSize)
}
// StoreVisualX stores the current visual x value in the cursor
func (c *Cursor) StoreVisualX() {
c.LastVisualX = c.GetVisualX()
}
// Relocate makes sure that the cursor is inside the bounds of the buffer
// If it isn't, it moves it to be within the buffer's lines
func (c *Cursor) Relocate() {