Fixes #5338. ListView.MoveUp/MoveDown cycles when TabStop == NoStop#5339
Merged
Conversation
Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/570bd4e3-1efe-4cb5-a20e-f9a8539afe16 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add tests for ListView movement cycling with NoStop behavior
Fixes #4891. ListView.MoveUp/MoveDown cycles when TabStop == NoStop
May 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a ListView movement bug and adds wrap-around behavior gated by TabStop. When TabStop == TabBehavior.NoStop, MoveDown at the bottom wraps to the first item and MoveUp at the top wraps to the last; otherwise the methods now correctly return false at the boundary. Also fixes a latent bug where MoveDown returned true from the "scroll viewport" branch when no frame had been set (Viewport.Height == 0).
Changes:
- Add
Viewport.Height > 0guard toMoveDown's scroll-viewport branch so it no longer spuriously returnstruewith an unset frame. - Add
TabStop == NoStopwrap-around branches in bothMoveDown(→ item 0) andMoveUp(→ last item). - Add 4 new tests for the wrap/return-false behavior and update 4 existing assertions that previously masked the scroll-guard bug.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Terminal.Gui/Views/ListView/ListView.Movement.cs | Adds viewport-height guard and NoStop wrap-around branches in MoveDown/MoveUp. |
| Tests/UnitTestsParallelizable/Views/ListViewTests.cs | Adds wrap/boundary tests; corrects 4 prior assertions that depended on the buggy true return. |
…behavior Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/53c94fb0-98ab-4611-afa4-36c10b1580dd Co-authored-by: tig <585482+tig@users.noreply.github.com>
This was referenced May 21, 2026
This was referenced May 28, 2026
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.
ListView.MoveDown/MoveUpnow wrap around to the opposite end of the list whenTabStop == TabBehavior.NoStop, and returnfalseat boundaries whenTabStopis anything else.Proposed Changes/Todos
MoveDown(ListView.Movement.cs): addedViewport.Height > 0guard on the scroll-viewport early-return branch (it was spuriously returningtruewhen no frame was set); addedTabStop == NoStopbranch that selects item0instead of returningfalseMoveUp(ListView.Movement.cs): added matchingTabStop == NoStopbranch that selects the last item instead of returningfalse<remarks>XML doc to bothMoveDownandMoveUpdocumenting the wrap-around behavior whenTabStop == NoStopand thefalse-return behavior otherwiseListViewTests.cs)Assert.True(lv.NewKeyDownEvent(Key.Space.WithShift))assertions toAssert.Falseat list bottom — they previously passed only because the scroll-guard bug returnedtrue; bothCommand.Activate(plain-view design, Default View KeyBindings blocking HotKeyBinding #4759) andCommand.Downnow correctly returnfalsethere, while marking side-effects are unaffectedPull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)