File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed
Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -1163,15 +1163,19 @@ func (h *BufPane) DiffPrevious() bool {
11631163
11641164// Undo undoes the last action
11651165func (h * BufPane ) Undo () bool {
1166- h .Buf .Undo ()
1166+ if ! h .Buf .Undo () {
1167+ return false
1168+ }
11671169 InfoBar .Message ("Undid action" )
11681170 h .Relocate ()
11691171 return true
11701172}
11711173
11721174// Redo redoes the last action
11731175func (h * BufPane ) Redo () bool {
1174- h .Buf .Redo ()
1176+ if ! h .Buf .Redo () {
1177+ return false
1178+ }
11751179 InfoBar .Message ("Redid action" )
11761180 h .Relocate ()
11771181 return true
Original file line number Diff line number Diff line change @@ -253,11 +253,11 @@ func (eh *EventHandler) Execute(t *TextEvent) {
253253 ExecuteTextEvent (t , eh .buf )
254254}
255255
256- // Undo the first event in the undo stack
257- func (eh * EventHandler ) Undo () {
256+ // Undo the first event in the undo stack. Returns false if the stack is empty.
257+ func (eh * EventHandler ) Undo () bool {
258258 t := eh .UndoStack .Peek ()
259259 if t == nil {
260- return
260+ return false
261261 }
262262
263263 startTime := t .Time .UnixNano () / int64 (time .Millisecond )
@@ -266,15 +266,16 @@ func (eh *EventHandler) Undo() {
266266 for {
267267 t = eh .UndoStack .Peek ()
268268 if t == nil {
269- return
269+ break
270270 }
271271
272272 if t .Time .UnixNano ()/ int64 (time .Millisecond ) < endTime {
273- return
273+ break
274274 }
275275
276276 eh .UndoOneEvent ()
277277 }
278+ return true
278279}
279280
280281// UndoOneEvent undoes one event
@@ -303,11 +304,11 @@ func (eh *EventHandler) UndoOneEvent() {
303304 eh .RedoStack .Push (t )
304305}
305306
306- // Redo the first event in the redo stack
307- func (eh * EventHandler ) Redo () {
307+ // Redo the first event in the redo stack. Returns false if the stack is empty.
308+ func (eh * EventHandler ) Redo () bool {
308309 t := eh .RedoStack .Peek ()
309310 if t == nil {
310- return
311+ return false
311312 }
312313
313314 startTime := t .Time .UnixNano () / int64 (time .Millisecond )
@@ -316,15 +317,16 @@ func (eh *EventHandler) Redo() {
316317 for {
317318 t = eh .RedoStack .Peek ()
318319 if t == nil {
319- return
320+ break
320321 }
321322
322323 if t .Time .UnixNano ()/ int64 (time .Millisecond ) > endTime {
323- return
324+ break
324325 }
325326
326327 eh .RedoOneEvent ()
327328 }
329+ return true
328330}
329331
330332// RedoOneEvent redoes one event
You can’t perform that action at this time.
0 commit comments