From d52502cf34fa7eef3993ca2e95a8caf2d6db1a57 Mon Sep 17 00:00:00 2001 From: midichef <67946319+midichef@users.noreply.github.com> Date: Sun, 20 Oct 2024 13:24:25 -0700 Subject: [PATCH] [features-] fix cursor index in hide-uniform-cols --- visidata/features/layout.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/visidata/features/layout.py b/visidata/features/layout.py index 449ff711d..79e0c3a6b 100644 --- a/visidata/features/layout.py +++ b/visidata/features/layout.py @@ -40,11 +40,16 @@ def hide_col(vd, col): def hide_uniform_cols(sheet): if len(sheet.rows) < 2: return - for col in sheet.visibleCols: + idx = sheet.cursorVisibleColIndex + for i, col in enumerate(sheet.visibleCols): vals = (col.getTypedValue(r) for r in sheet.rows) first = next(vals) if all(v == first for v in vals): + vd.status(f'hide {col.name} with value: {col.getDisplayValue(sheet.rows[0])}') + if i <= idx: + sheet.cursorRight(-1) col.hide() + Sheet.clear_all_caches() #2578 Sheet.addCommand('_', 'resize-col-max', 'if cursorCol: cursorCol.toggleWidth(cursorCol.getMaxWidth(visibleRows))', 'toggle width of current column between full and default width') Sheet.addCommand('z_', 'resize-col-input', 'width = int(input("set width= ", value=cursorCol.width)); cursorCol.setWidth(width)', 'adjust width of current column to N')