refactor(tui): extract _select_origin_widget helper + add unit tests#376
Open
EthanGuo-coder wants to merge 1 commit into
Open
refactor(tui): extract _select_origin_widget helper + add unit tests#376EthanGuo-coder wants to merge 1 commit into
EthanGuo-coder wants to merge 1 commit into
Conversation
Refactor the Textual 8.x compat candidate-resolution that lsdefine#379 just landed in _patch_auto_scroll_for_selection. Extract the inline 8.x vs ≤7.x branch into a module-level _select_origin_widget(screen) helper, add a defensive None-guard on start (in case _select_state exists but start is None mid-drag), and cover both paths with unit tests stubbing screen — no real Textual required. Refs lsdefine#373, lsdefine#379 Co-Authored-By: Claude <noreply@anthropic.com>
09b68b9 to
38013e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up refactor on top of #379, which already landed the Textual 8.x compat shim inline inside
_patch_auto_scroll_for_selection.Changes:
_select_statevs_select_startbranch into a module-level helper_select_origin_widget(screen). The call site becomes a one-liner.None-guard on_select_state.start. The current inline version assumesstartis always present whenever_select_stateis — that holds for the Textual 8.2.6 shape today, but the helper degrades gracefully if a future version exposes a mid-drag_select_statewhosestartis stillNone.tests/test_tuiapp_v2_select_origin.pywith 6 unit tests stubbingscreendirectly (no real Textual instance required) to cover:_select_state.start.container._select_state is None— returnsNone.start is None— returnsNone._select_start[0]._select_start is None— returnsNone.None.No behaviour change for users on the path #379 already covers. Rebased onto current
main(fc6b5ad).Refs #373, #379