Repository navigation
fix(textarea): navigate and delete whole graphemes - #1067
rupayon123 wants to merge 2 commits into
Conversation
andrinoff
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
| m.SetCursorColumn(m.col - 1) | ||
| } | ||
| start, _ := graphemeAt(m.value[m.row], m.col-1) | ||
| m.value[m.row] = append(m.value[m.row][:start], m.value[m.row][m.col:]...) |
There was a problem hiding this comment.
The cursor can still land in the middle of a cluster (moving up/down between lines, clicking, or SetCursorColumn)
There was a problem hiding this comment.
129c18e snaps SetCursorColumn to the cluster start and normalizes the cursor after vertical movement. I reproduced both failures before the change and added regressions. Forward word operations also advance by grapheme so the new snapping cannot leave them stuck. The full Go 1.26.0 test suite and go vet pass; interactive mouse/terminal behavior has not been tested.
| if m.col > 0 { | ||
| m.SetCursorColumn(m.col - 1) | ||
| } | ||
| start, _ := graphemeAt(m.value[m.row], m.col-1) |
There was a problem hiding this comment.
Backspace now deletes the whole cluster, so in Thai or Hindi one press wipes a consonant and all its marks. This is very important
There was a problem hiding this comment.
I restored one-code-point Backspace in 129c18e. The Thai and Hindi regressions now check that removing a mark preserves the consonant. Forward Delete still removes a full grapheme. I also corrected the earlier Thai test that incorrectly expected Backspace to erase the whole cluster. The full test suite passes.
Refs #1061.
The textarea preserves rune-index positions while using grapheme boundaries for character navigation and forward deletion. SetCursorColumn snaps an interior position to the grapheme start, and vertical movement normalizes the final cursor position. Backspace retains one-code-point deletion so Thai and Hindi marks can be corrected without erasing their consonant. Forward word operations now advance across whole graphemes to avoid getting stuck after cursor snapping.
Validation (Go 1.26.0): three new regressions reproduced interior SetCursorColumn, vertical cursor and consonant-deleting backspace failures before the repair. The repaired textarea suite and full go test ./... suite pass, as do go vet ./... and git diff --check. Added word-navigation/deletion coverage for Hindi, Thai, combining accents and emoji. The earlier Thai backspace assertion was corrected to the requested code-point semantics; it no longer requires deleting the whole cluster.
Local golangci-lint is unavailable; remote lint and the test matrix on the new head remain to be verified. No interactive terminal/mouse or native-language usability test was performed.