Skip to content

Fix infinite loop in textarea wordLeft navigation#987

Open
haofan wants to merge 2 commits into
charmbracelet:mainfrom
haofan:fix-textarea-wordleft-loop
Open

Fix infinite loop in textarea wordLeft navigation#987
haofan wants to merge 2 commits into
charmbracelet:mainfrom
haofan:fix-textarea-wordleft-loop

Conversation

@haofan
Copy link
Copy Markdown

@haofan haofan commented May 22, 2026

When navigating left in a textarea, if we encounter spaces at the very beginning of the input (col=0, row=0), the loop to skip spaces would run infinitely because characterLeft does nothing at the beginning and the cursor never advances.

This PR adds a boundary check to break the loop if the cursor reaches col=0, row=0.

Haofan Zhang added 2 commits May 22, 2026 06:20
When navigating left in a textarea, if we encounter spaces at the very
beginning of the input (col=0, row=0), the loop to skip spaces would
run infinitely because characterLeft does nothing at the beginning
and the cursor never advances.

This PR adds a boundary check to break the loop if the cursor reaches
col=0, row=0.
This adds TestWordLeftInfiniteLoopRepro to textarea_test.go to verify
the wordLeft boundary fix.
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.

1 participant