Repository navigation
Conversation
size() returned get_size(): the window (the screen, on mobile) divided by a fixed 10x20 cell. The grid is the parent divided by the measured cell. When the frame came out larger than the grid, draw indexed past the last cell and panicked. Measure in the resize listener instead of in draw, so size() reports the new grid size before ratatui draws, and rebuild the grid at that size in the next draw.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #188.
size()returnedget_size(), a window (on mobile, screen) size divided by a fixed 10×20 cell, while the grid is the parent divided by the measured cell. When the frame was larger than the grid,drawindexed past the last cell and panicked (on phones, or with any cell larger than 10×20 on desktop).Change
size()returns that pending size, or the current grid's size, and the nextdrawrebuilds the grid at it.draw: ratatui callssize()(autoresize) beforedraw, so asize()that read the grid would always be one resize behind.initializedis now a plainbool, since onlydrawtouches it.Behavior changes
- 1margin is gone.draw. Withdraw_web, which draws inrequestAnimationFrame, the browser runs resize handlers before animation frame callbacks in the same rendering update, so the empty parent isn't painted. An app drawing from some other timer could show one blank frame after a resize.Tests
Two
wasm_bindgen_tests indom.rscheck thatterminal.size()equals the rows × columns of the grid in the DOM, after the first draw and after aresize. Both panic onmainand pass here.wasm-pack test --firefox --headless,cargo test --all-features --all-targets,cargo fmt --checkandcargo docpass; clippy reports no new warnings.Not in this PR
get_size()is unchanged; the canvas backend still uses it.set_inner_html(""), asdrawdid before, which also removes anything else in the parent. Removing only the grid would be narrower.Possibly related: #186. #167 (draft) also changes how
size()is computed.