Flatten deep nesting in _multiselect_loop #292
Reference in New Issue
Block a user
Delete Branch "flatten-deep-nesting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #288.
Summary
_multiselect_loopinbot_bottle/cli/tui.pynested key dispatch up to six indent levels — the space-bar toggle (while→if focus == "filter"→elif key == SPACE→if filtered→if/elsemembership) and the long order-modeelifchain wrapped inside the focus branch.Two behaviour-identical helpers pull it back under four levels:
_toggle_membership(items, item)— collapses the add/removeif/else, flattening the space branch._handle_order_key(key, selected, order_cursor)— moves the whole order-focus dispatch out of the loop and returns the new cursor.No key bindings or control flow change; the loop's early returns and focus toggling are untouched. The extracted helpers are covered by a behavioural sanity check (toggle, reorder up/down, remove, navigate) and the full unit suite (1297 tests) passes; pyright clean.
Note on git_gate.py
The deep-looking lines in
git_gate.pynamed in the issue are multiline call-argument continuations, already under four levels of actual control nesting, so no change was warranted there. The flattening is focused where it mattered.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.