Skip to content

Commit

Permalink
[features-] fix cursor index in hide-uniform-cols
Browse files Browse the repository at this point in the history
  • Loading branch information
midichef committed Nov 10, 2024
1 parent bee4116 commit 45feb70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion visidata/features/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'hid col {col.name} with value: {repr(first)}')
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')
Expand Down

0 comments on commit 45feb70

Please sign in to comment.