Clear cursors before performing undo or redo

This fix isn't ideal because it removes the cursors but it does work

Fixes #798
This commit is contained in:
Zachary Yedidia
2017-09-04 15:47:24 -04:00
parent 4fcdde4149
commit efff850e54
3 changed files with 32 additions and 10 deletions

View File

@@ -479,9 +479,14 @@ func (v *View) ExecuteActions(actions []func(*View, bool) bool) bool {
return relocate
}
func (v *View) SetCursor(c *Cursor) {
func (v *View) SetCursor(c *Cursor) bool {
if c == nil {
return false
}
v.Cursor = c
v.Buf.curCursor = c.Num
return true
}
// HandleEvent handles an event passed by the main loop
@@ -505,7 +510,10 @@ func (v *View) HandleEvent(event tcell.Event) {
}
if e.Modifiers() == key.modifiers {
for _, c := range v.Buf.cursors {
v.SetCursor(c)
ok := v.SetCursor(c)
if !ok {
break
}
relocate = false
isBinding = true
relocate = v.ExecuteActions(actions) || relocate
@@ -553,7 +561,6 @@ func (v *View) HandleEvent(event tcell.Event) {
for _, c := range v.Buf.cursors {
v.SetCursor(c)
v.paste(e.Text())
}
v.SetCursor(&v.Buf.Cursor)
@@ -568,7 +575,10 @@ func (v *View) HandleEvent(event tcell.Event) {
for key, actions := range bindings {
if button == key.buttons && e.Modifiers() == key.modifiers {
for _, c := range v.Buf.cursors {
v.SetCursor(c)
ok := v.SetCursor(c)
if !ok {
break
}
relocate = v.ExecuteActions(actions) || relocate
}
v.SetCursor(&v.Buf.Cursor)