Flatten deep nesting in _multiselect_loop #292

Open
didericis-claude wants to merge 1 commits from flatten-deep-nesting into main

1 Commits

Author SHA1 Message Date
didericis 4ab48a77ff refactor(tui): flatten _multiselect_loop key handling
lint / lint (push) Successful in 1m49s
test / unit (pull_request) Successful in 43s
test / integration (pull_request) Successful in 19s
The interactive multiselect loop nested key dispatch up to six indent
levels deep — the worst offender being the space-bar toggle
(while > if focus > elif key > if filtered > if/else membership) and
the long order-mode elif chain inside the focus branch.

Extract two behaviour-identical helpers:
- `_toggle_membership(items, item)` collapses the add/remove if/else,
  pulling the space branch back to four levels.
- `_handle_order_key(key, selected, order_cursor)` moves the entire
  order-focus dispatch out of the loop, returning the new cursor.

No control-flow or key-binding changes; the loop's early returns and
focus toggling are untouched. (git_gate.py's deep-looking lines named
in the issue are multiline call-argument continuations already under
four levels of control nesting, so no change was warranted there.)

Closes #288

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkwFXLFff9PYPy4wgVBJp9
2026-06-25 19:38:46 -04:00