Skip to content

fix(textarea): reposition view after SetValue#998

Open
troclaux wants to merge 1 commit into
charmbracelet:mainfrom
troclaux:fix/textarea-setvalue-reposition
Open

fix(textarea): reposition view after SetValue#998
troclaux wants to merge 1 commit into
charmbracelet:mainfrom
troclaux:fix/textarea-setvalue-reposition

Conversation

@troclaux
Copy link
Copy Markdown

@troclaux troclaux commented Jun 2, 2026

Problem

When SetValue is called with content taller than the textarea viewport, the viewport is not scrolled to show the cursor position. The cursor ends up on the last line of the content, but repositionView() was never called to adjust the scroll offset.

Fix

Call m.repositionView() at the end of SetValue, consistent with how other content-insertion paths work.

Test

Added TestSetValueViewportReposition which sets a 3-line viewport, calls SetValue with 5 lines, and asserts the cursor line is within the visible range.

Fixes #231

SetValue was not scrolling the viewport to show the cursor after
inserting content taller than the textarea height.

Fixes charmbracelet#231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

textarea: SetValue with input taller than viewport does not position cursor properly

1 participant