Skip to content

fix(textarea): cursor stuck at exact soft-wrap width#981

Open
leno23 wants to merge 1 commit into
charmbracelet:mainfrom
leno23:fix/textarea-cursor-exact-width-wrap-887
Open

fix(textarea): cursor stuck at exact soft-wrap width#981
leno23 wants to merge 1 commit into
charmbracelet:mainfrom
leno23:fix/textarea-cursor-exact-width-wrap-887

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes #887.

When a soft-wrapped line exactly filled the textarea width, wrap() used >= width and created a phantom blank line. Vertical navigation also stopped one display column early because setCursorLineRelative broke when offset >= CharWidth-1.

Changes

  • Use > width in the final wrap() width check so content that exactly fits does not spawn an extra line
  • Compare offset >= CharWidth when restoring horizontal cursor position after moving up/down
  • Update TestView cursor expectations that depended on the phantom wrap line

Test plan

  • go test ./textarea/...
  • TestWrapExactWidthNoPhantomLine
  • TestCursorDownPastExactWidthLine

Made with Cursor

When soft-wrapped content exactly filled the textarea width, wrap() used
>= and created a phantom blank line, and vertical cursor movement stopped
one column early (offset >= CharWidth-1) (charmbracelet#887).

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Cursor gets stuck when navigating up/down in textarea

1 participant