Skip to content

Commit 59344b6

Browse files
midichefanjakefala
authored andcommitted
[aggr-] allow undo for aggregate-col/cols
1 parent 396d248 commit 59344b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

visidata/aggregators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import functools
44
import collections
55
import statistics
6+
from copy import copy
67

78
from visidata import Progress, Sheet, Column, ColumnsSheet, VisiData
89
from visidata import vd, anytype, vlen, asyncthread, wrapply, AttrDict, date, INPROGRESS
@@ -205,10 +206,9 @@ def addAggregators(sheet, cols, aggrnames):
205206
for aggrname in aggrnames:
206207
aggrs = vd.aggregators.get(aggrname)
207208
aggrs = aggrs if isinstance(aggrs, list) else [aggrs]
208-
for aggr in aggrs:
209-
for c in cols:
210-
if not hasattr(c, 'aggregators'):
211-
c.aggregators = []
209+
for c in cols:
210+
vd.addUndo(setattr, c, 'aggregators', copy(c.aggregators))
211+
for aggr in aggrs:
212212
if aggr and aggr not in c.aggregators:
213213
c.aggregators += [aggr]
214214

0 commit comments

Comments
 (0)