From 13d1407f60a12b2c450074887bc821f64350a635 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Fri, 23 Oct 2020 00:17:22 +0200 Subject: [PATCH] hltrailingws: simpler and better undo/redo handling --- internal/buffer/eventhandler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/buffer/eventhandler.go b/internal/buffer/eventhandler.go index 6dfb32a0..53f64025 100644 --- a/internal/buffer/eventhandler.go +++ b/internal/buffer/eventhandler.go @@ -107,7 +107,9 @@ func (eh *EventHandler) DoTextEvent(t *TextEvent, useUndo bool) { c.LastVisualX = c.GetVisualX() } - eh.updateTrailingWs(t) + if useUndo { + eh.updateTrailingWs(t) + } } // ExecuteTextEvent runs a text event @@ -292,6 +294,7 @@ func (eh *EventHandler) UndoOneEvent() { if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { t.C = *eh.cursors[teCursor.Num] eh.cursors[teCursor.Num].Goto(teCursor) + eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY } else { teCursor.Num = -1 } @@ -335,6 +338,7 @@ func (eh *EventHandler) RedoOneEvent() { if teCursor.Num >= 0 && teCursor.Num < len(eh.cursors) { t.C = *eh.cursors[teCursor.Num] eh.cursors[teCursor.Num].Goto(teCursor) + eh.cursors[teCursor.Num].NewTrailingWsY = teCursor.NewTrailingWsY } else { teCursor.Num = -1 }