refactor: Extract shared layout computation from painter#1021
Merged
fdncred merged 2 commits intonushell:mainfrom Feb 5, 2026
Merged
refactor: Extract shared layout computation from painter#1021fdncred merged 2 commits intonushell:mainfrom
fdncred merged 2 commits intonushell:mainfrom
Conversation
Replace the redundant `right_prompt_rendered` bool and three separate Option fields with a single `Option<RightPromptBounds>` struct in both PromptLayout and RenderSnapshot, ensuring the fields are always set or unset together. Add unit tests for compute_layout.
Contributor
|
Nice cleanup. Thanks! |
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.
PromptLayoutstruct computed once per paint cycle incompute_layout, eliminating duplicated layout math acrossprint_large_buffer,print_right_prompt,print_menu, andrender_snapshotrender_snapshotrendered the right prompt for large buffers even when the prompt had scrolled off-screen (extra_rows > 0), diverging fromprint_large_bufferwhich correctly suppressed itcompute_layout(small/large buffer, right prompt visibility, scrolling math, multi-line prompt)Motivation
render_snapshotduplicated layout calculations fromprint_large_buffer,print_right_prompt, andprint_menu. Any change to one had to be mirrored in the other, and they had already drifted (the right-prompt suppression bug).Changes
src/painting/painter.rsPromptLayoutstruct holding all layout values: extra rows, large buffer offset, right prompt bounds, menu start row, first buffer columnPainter::compute_layout()that consolidates the 5 duplicated computations into a single callPainter::last_layoutfield storing the layout from the most recent paint cyclerepaint_bufferto callcompute_layoutand thread the result throughprint_large_buffer,print_small_buffer,print_right_prompt, andprint_menurender_snapshotto copy values from the layout instead of recomputing them