Skip to content

Cursor gets stuck when navigating up/down in textarea #887

@geordee

Description

@geordee

Description
When using a textarea component, the cursor can get stuck and stop responding to up/down arrow key navigation. This might be due to off-by-one errors in the boundary condition checks within CursorDown() and CursorUp(). The comparison offset >= nli.CharWidth-1 exits the cursor positioning loop one iteration too early, preventing the cursor from reaching the correct column position on the target line.

Also when the content of a line (including spaces) exactly equals the textarea width, the wrap() function incorrectly creates an extra empty line. The condition >= width triggers a line wrap even when the content fits perfectly within the available width, producing a phantom blank line in the display. You can reach the last character using Ctrl+E, but not using down arrow key.

Setup

  • OS: Any
  • Shell: Any
  • Terminal Emulator: Any
  • Terminal Multiplexer: N/A
  • Locale: N/A

Steps

  1. Create a textarea with a specific width (e.g., 20 characters)
  2. Type a line of text where the total content (text + spaces) adds up to exactly the textarea width
  3. Observe an unexpected empty line appearing below the text
  4. Observe the cursor gets stuck and does not move beyond this line

Source Code

Screenshots
Image

Refer the screenshot to see how the issue is recreated in story time example. Once setup, please try moving paste line 3 using down arrow key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions