-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(list): Modify List and List example to support saving offsets. #667
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #667 +/- ##
=====================================
Coverage 92.4% 92.5%
=====================================
Files 61 61
Lines 16262 16290 +28
=====================================
+ Hits 15042 15070 +28
Misses 1220 1220 ☔ View full report in Codecov by Sentry. |
I personally think this PR is probably the right thing to do (i.e. don't reset offset when unselecting). It was mentioned recently in another PR / issue, but I don't know the history of why this current behavior is like it is. Would you mind digging into the tui-rs history to find some details on the existing behavior if possible? The questions I'd generally ask about odd behavior like this are (a non-exhaustive list):
Assuming that we go ahead with this change, this PR needs a few extra things:
|
I like this change and I think it is something nice to have in the long run. Seconding Josh here and I would like to add |
I've looked through the discussions and issues in tui-rs and found nothing. I've also browsed the git history, which indicates this behavior was added when That said I'm still unsure if this was intentional behavior after reading through these bits. However, this change to
Currently, the offset will always be 0 when
Finally, let's look at the pre-PR line in
With the pre-PR setup, whenever the user
Because of this I do not believe this change is breaking or changes pre-existing behavior. |
Thanks for doing the history dive on. Your findings make me much less concerned that it was intentional and more like something that just seemed right at the time. I have to admit that I don't know this code deeply (you're more of an expert on it right now than anyon), but if you can change a line in a private method without breaking any unit tests, I think there's a problem somewhere - possibly in the existing unit test coverage of that line. Incidentally I can change it to 1 or 2 and all the tests still pass (but not 3). Can you add a test that shows how this change impacts things (rendering / state)? It might be helpful to the next person to look at that code to also to add a comment that explains why that method exists. If you can discern the intent, writing it down helps validate that the change is correct. |
Two things:
The gist of why that test was previously failing is because of the way rendering happens for the |
Thank you very much for the detailed explanations and suggestions. In this push I've removed some of the comments and made some changes to variable names as suggested. I will address potential optimizations/readability with iterators and ranges in a future PR if that is okay with everyone. |
Sounds good. There seems to be a conflict with |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a small message that explains the change for the Changelog? (i.e. a one liner for the title of the change and a more full message for the body). If you're familiar with rebasing and squashing your changes, feel free to force push a single commit with the updated message, otherwise we can apply one for you using the github squash and merge. (Note - you may have to pull that commit above into your local branch)
a6d8c64
to
33909c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appart from the test, would be happy to merge that
33909c3
to
f97fd8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Do you want to move your initial test to an integration test?
Hey @bblsh, do you still want to work on this. We couldn't merge it at the time because of unsigned commit and kind of forgot to tell you 😓. If you still want to work on this, it will need to be rebased on main. If you could sign your commits that's be great (we need all commits to be signed so the easiest is to squash them). Don't hesitate to ask for help if needed! EDIT: You can find help on signing in CONTRIBUTING.md or on Github doc |
f97fd8a
to
40cdf64
Compare
Thank you for opening this pull request! We require commits to be signed and it looks like this PR contains unsigned commits. Get help in the CONTRIBUTING.md |
This allows the offset of a list's state to be set, even if the list has been unselected.
40cdf64
to
99ab834
Compare
Thank you for opening this pull request! We require commits to be signed and it looks like this PR contains unsigned commits. Get help in the CONTRIBUTING.md |
Rebased and signed! Thanks for the reminder. |
Thanks! |
The current
List
example will unselect and reset the position of a list.This PR will save the last selected item, and updates
List
to honor its offset, preventing the list from resetting when the userunselect()
s aStatefulList
.