-
Notifications
You must be signed in to change notification settings - Fork 263
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
Table: Make UpdateViewport() have constant runtime, not depending on … #284
Conversation
…number of rows in a table
Thank you @pja237, this is super appreciated. Nice work! |
One thing I noticed when playing around with this is that the cursor is not working properly when scrolling. The cursor should behave like the first table where it is on the last / first row depending on whether it is scrolling down / up. Screen.Recording.2022-11-04.at.10.26.08.AM.mov |
👍 haven't noticed that, thanks! |
Thanks! This is a great improvement, really looking forward to see it merged! |
Hey @maaslalani , |
table/table.go
Outdated
renderedLines | ||
} | ||
|
||
type renderedLines struct { | ||
start, end int |
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 think we can get rid of this renderedLines
struct and replace it as end
and start
on the model. What do you think?
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.
Absolutely fine with me, was just a distinction between original table struct and added values, pushed a commit with change
Tested this out and it works great! Thank you so much @pja237. Great work! |
You're very welcome! |
@maaslalani Anything blocking this or can we merge? |
To keep this alive and let you know, i've been in contact with @maaslalani on discord regarding this pr and we concluded that it's good to go, but of course, we should wait for him on this. Just posting this so it doesn't fizzle out, would love to see this merged |
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.
Yep, this one is good to go!
Thanks @pja237 for the awesome work ❤️ |
…number of rows in a table.
Related issue: #276
Since there was no feedback on the issue, i tried the following approach to solve the problem of table becoming pretty much useless for a large number of rows.
Instead of rendering the whole table, i limited the rendering to only rows from: m.cursor-m.viewport.Height to: m.cursor+m.viewport.Height. This approach gives the constant runtime (see below) making table act snappy and responsive independent on the number of rows in it.
Results, timed by measuring time to execute a MoveDown(1):
This code works fine in my app , although i'm not sure if it might have any adverse effect in some other table code-paths?
Can't see any for now. If you spot anything, let me know! 😺