Skip to content

Commit

Permalink
Merge pull request #2010 from midichef/undo_order
Browse files Browse the repository at this point in the history
[undo] remove last matching cmdlog row, instead of first
  • Loading branch information
anjakefala authored Sep 3, 2023
2 parents 6c6d991 + 233981d commit 6358c94
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions visidata/undo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ def undo(vd, sheet):
vd.fail("options.undo not enabled")

# don't allow undo of first command on a sheet, which is always the command that created the sheet.
for cmdlogrow in sheet.cmdlog_sheet.rows[:0:-1]:
for i, cmdlogrow in enumerate(sheet.cmdlog_sheet.rows[:0:-1]):
if cmdlogrow.undofuncs:
for undofunc, args, kwargs, in cmdlogrow.undofuncs[::-1]:
undofunc(*args, **kwargs)
sheet.undone.append(cmdlogrow)
sheet.cmdlog_sheet.rows.remove(cmdlogrow)
row_idx = len(sheet.cmdlog_sheet.rows)-1 - i
del sheet.cmdlog_sheet.rows[row_idx]

vd.clearCaches() # undofunc can invalidate the drawcache

Expand Down

0 comments on commit 6358c94

Please sign in to comment.