Skip to content

Commit

Permalink
[aggr-] allow undo for aggregate-col/cols
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Nov 10, 2024
1 parent bee4116 commit a9efd4b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions visidata/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import collections
import statistics
from copy import copy

from visidata import Progress, Sheet, Column, ColumnsSheet, VisiData
from visidata import vd, anytype, vlen, asyncthread, wrapply, AttrDict, date, INPROGRESS
Expand Down Expand Up @@ -205,10 +206,9 @@ def addAggregators(sheet, cols, aggrnames):
for aggrname in aggrnames:
aggrs = vd.aggregators.get(aggrname)
aggrs = aggrs if isinstance(aggrs, list) else [aggrs]
for aggr in aggrs:
for c in cols:
if not hasattr(c, 'aggregators'):
c.aggregators = []
for c in cols:
vd.addUndo(setattr, c, 'aggregators', copy(c.aggregators))
for aggr in aggrs:
if aggr and aggr not in c.aggregators:
c.aggregators += [aggr]

Expand Down

0 comments on commit a9efd4b

Please sign in to comment.