Skip to content

refactor(tui): extract _select_origin_widget helper - #376

Open
EthanGuo-coder wants to merge 1 commit into
lsdefine:mainfrom
EthanGuo-coder:fix/issue-373
Open

refactor(tui): extract _select_origin_widget helper#376
EthanGuo-coder wants to merge 1 commit into
lsdefine:mainfrom
EthanGuo-coder:fix/issue-373

Conversation

@EthanGuo-coder

@EthanGuo-coder EthanGuo-coder commented May 14, 2026

Copy link
Copy Markdown

The previous head was based on fc6b5ad, which is no longer in main's history after the recent force-push, so this PR was rendering a bogus 250-commit / 100-file diff against an ancient merge base. Re-applied cleanly on top of 4086d5c. The test file the original description mentioned has been dropped, since the tree carries no test suite and no pytest dependency.

Changes:

  • Extract the inline Textual 8.x / ≤7.x branch in _patch_auto_scroll_for_selection into a module-level _select_origin_widget(screen) helper at the top of the # ---------- App ---------- section. The call site becomes a one-liner.
  • Guard .start before dereferencing it. This is future-proofing rather than a fix for a currently reachable state: SelectState.start is non-optional in Textual 8.2.6, so the existing select_state.start.container cannot raise on any shape Textual produces today. The guard only means that a future private-API change degrades to "no extra auto-scroll candidate" instead of an AttributeError raised inside a mouse-move handler.

No behaviour change on any input Textual produces today. Verified by running the current inline implementation and the helper side by side over a 20-case matrix covering every presence / absence / None combination of _select_state, _select_state.start and _select_start: 12 cases identical, and the only 8 differences are exactly the guard described above — the inline version raises AttributeError, the helper returns None. An empty _select_start tuple still raises IndexError in both, unchanged.

Refs #373, #379

@EthanGuo-coder EthanGuo-coder changed the title fix(tui): compat tuiapp_v2 selection auto-scroll with Textual 8.x refactor(tui): extract _select_origin_widget helper + add unit tests May 15, 2026
@EthanGuo-coder EthanGuo-coder changed the title refactor(tui): extract _select_origin_widget helper + add unit tests refactor(tui): extract _select_origin_widget helper Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant