Skip to content
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 dubious unwrap in TUI #357

Open
osa1 opened this issue Sep 14, 2021 · 0 comments
Open

Fix dubious unwrap in TUI #357

osa1 opened this issue Sep 14, 2021 · 0 comments
Labels
bug libtiny_tui Issues/PRs related to the TUI library question

Comments

@osa1
Copy link
Owner

osa1 commented Sep 14, 2021

Originally discussed in #356 (review)

self.recalculate_scroll(old_height, old_total_lines.unwrap());

This unwrap will probably cause a panic when we resize twice without drawing in between.

We could probably get the height with self.update_total_visible_lines instead of unwrapping self.lines_height, which would fix the issue, but I think a better fix would be to delay calculating the scroll value until needed, similar to line heights. There seems to be no reason to compute scroll values eagerly on resize while line heights are only computed when drawing. Why not do both when drawing?

@osa1 osa1 added bug question libtiny_tui Issues/PRs related to the TUI library labels Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug libtiny_tui Issues/PRs related to the TUI library question
Projects
None yet
Development

No branches or pull requests

1 participant