textarea: reset viewport when auto-resized wrapped content fully fits#913
Open
yogirk wants to merge 1 commit intocharmbracelet:mainfrom
Open
textarea: reset viewport when auto-resized wrapped content fully fits#913yogirk wants to merge 1 commit intocharmbracelet:mainfrom
yogirk wants to merge 1 commit intocharmbracelet:mainfrom
Conversation
When a host app auto-resizes textarea height to match the current number of soft-wrapped rows, a stale viewport offset could hide the first wrapped row even though the full content fits. Fix repositionView to snap the viewport to top when all soft-wrapped rows fit within the current textarea height. Add a regression test that simulates keypress-driven autoresize.
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
textareaheight to match the current number of soft-wrapped rows (e.g. after each keypress), a staleviewport.YOffsetcan hide the first wrapped row — even though the entire buffer now fits within the visible area.repositionView(), if the total soft-wrapped line count fits within the viewport height, snap the viewport to top before applying cursor-following logic.Repro
textareawith a constrained width and height of 1Test plan
TestAutoResizeKeepsFirstSoftWrappedRowVisiblepassestextareatests passgo test ./...passes