Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[features-] fix cursor index in hide-uniform-cols #2578

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'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')
Expand Down
Loading