Skip to content

Fix forward word deletion at the end of a text input - #1058

Open
rupayon123 wants to merge 1 commit into
charmbracelet:mainfrom
rupayon123:fix/textinput-forward-word-boundary-20260924
Open

rupayon123 wants to merge 1 commit into
charmbracelet:mainfrom
rupayon123:fix/textinput-forward-word-boundary-20260924

Conversation

@rupayon123

Copy link
Copy Markdown

Problem

In textinput, Alt+D panics when the cursor is on the final rune of the value. When the cursor is on the final rune of a word followed by another word, it also deletes that next word (#1056).

Change

Scan from the current rune using a separate end index. Only skip whitespace when deletion starts on whitespace; then stop at the next word boundary. This avoids indexing beyond the value and preserves the existing behavior for deletion starting on a space. The new Update-driven regression covers the reported cases and a Unicode rune.

Validation

  • New regression failed before the fix with the extra-word deletion and index panic; passed afterward.
  • go test ./textinput -count=1 — passed.
  • go test ./... — passed.
  • go test -race ./textinput -count=1 — passed.
  • go vet ./..., gofmt -d on changed files, and git diff --check — passed.

Tested with Go 1.27.1 against the module's Go 1.25 baseline. Prepared with AI assistance.

Fixes #1056.

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.

textinput: alt+d panics on the last rune of the value and deletes an extra word on the last rune of a word

1 participant