Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Fix out of bounds table offset panic #459

Closed
wants to merge 2 commits into from

Conversation

benhall-7
Copy link

So I have a TUI project I'm working on where I've supplied a method to filter out data from the Table widget, using a regex match. Whenever I do this I want to preserve the previous table state, so that the table can still scroll up or down relative to its previous position. For example, if just 1 entry were removed it would be preferable to preserve the offset instead of reset it to 0 and scroll down to the currently selected element. The issue this led to was an out-of-bounds index whenever the offset was greater than the length of the new data. The fix takes only 1 line: clamp the offset to the last index in the new list.

@fdehau
Copy link
Owner

fdehau commented Aug 1, 2021

Thanks a lot for the detailed report. I've fixed this in #516 to add tests and fix it in List which had the same issue.

@fdehau fdehau closed this Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants