refactor(painter): record a resize as a cursor row, not a prompt row - #1213
Open
kronberger-droid wants to merge 1 commit into
Open
refactor(painter): record a resize as a cursor row, not a prompt row#1213kronberger-droid wants to merge 1 commit into
kronberger-droid wants to merge 1 commit into
Conversation
`prompt_start_row` held a cursor row whenever `just_resized` was set, so any path that rewrote the row without clearing the flag (`anchor_prompt`, `clear_screen`, `print_external_message`) left the next paint subtracting from a row that was already a prompt row. `Resized` carries the cursor row in the state itself, thus the two cannot come apart. The resolved row is now `Verified`, which drops one `cursor::position()` per resize. The drift check that query fed re-anchors only when the cursor sits above the cached row, and a row reached by subtracting from that same cursor never does, so the answer could not change.
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.
Summary
handle_resizestores the cursor row inprompt_start_row, which everywhere else holds the row the prompt starts on, and ajust_resizedbool told the two apart.Every path that writes the row has to keep that bool in step, and
anchor_prompt,clear_screenandprint_external_messageall write it without touching the flag, so a resize whose paint never came leaves a later paint subtracting from a row that was already a prompt row.A
Resized { cursor_row }variant makes that unrepresentable, since the state itself says which row it holds.No public API change,
PromptStartRowand its methods are allpub(crate).After
repaint_bufferresolves it withresolve_resize(lines_before_cursor)where the old block was, andjust_resizedis gone.The resolved row is
Verifiedrather thanStale, thus onecursor::position()per resize goes away.That query fed the drift check, which re-anchors only when the measured cursor sits above the cached row, and a row reached by subtracting from that same cursor never is, so it could not change the answer.