visidata icon indicating copy to clipboard operation
visidata copied to clipboard

[cmdlog] when key column values are not unique, row commands refer to incorrect rows

Open midichef opened this issue 5 months ago • 1 comments

Small description Whem working on a sheet with a key column that repeats values, row commands will be logged for incorrect rows. The row commands will incorrectly refer to the first row that matched the ambiguous key value, even when they should refer to the second, third, etc.

With a starting sheet of:

key	order
repeat	1
repeat	2
repeat	3

Make key a key column, slide the middle row (repeat, 2) down 1 row, then undo and redo the command: ! Down J U then R

Expected result

key	order
repeat	1
repeat	3
repeat	2

Actual result with screenshot

key	order
repeat	2
repeat	1
repeat	3

Steps to reproduce with sample data and a .vd cmdlog_ambiguous_row.csv vd cmdlog_ambiguous_row.csv

Additional context visidata v3.1dev

If there are no key columns, everything works as expected. The ambiguous row recording happens here: https://github.com/saulpw/visidata/blob/5772c0f5e817fba2a7a1f9f5949cb959067cebca/visidata/cmdlog.py#L128-L130

midichef avatar Jan 10 '24 09:01 midichef