-
Notifications
You must be signed in to change notification settings - Fork 844
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(listview): update index after items removed #5135
fix(listview): update index after items removed #5135
Conversation
I've now also updated the |
This now also reinstates |
I'd recommend against the Better to factor out the specific functionality you need and call it directly. TBH I regret adding self.index = self.index |
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.
Just a request for docstrings...
src/textual/widgets/_list_view.py
Outdated
item_to_remove = self.query("ListItem")[index] | ||
normalized_index = index if index >= 0 else index + len(self) | ||
|
||
async def do_pop(): |
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.
Docstring and typing por favor. Since its internal, and essentially private, the docstrings can be written for future Textual core-devs.
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.
I've added docstrings in 9314cde, but feel free to tweak!
src/textual/widgets/_list_view.py
Outdated
index if index >= 0 else index + len(self) for index in indices | ||
) | ||
|
||
async def do_remove_items(): |
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.
docstrings please
Hi Tom, is this ready to go? |
@willmcgugan If you're happy with my approach and the added tests cover all cases, I think this should be ready to go. |
@willmcgugan I was going to merge, but it's blocked until you approve. |
Fixes #5114.
pop
andremove_items
methods now returnAwaitComplete
rather thanAwaitRemove
to account for the index updatepop()
from an empty list would raise aNoMatches
error, this will now raise anIndexError
for consistency.Please review the following checklist.