Fix backspace handling on Android.

This commit is contained in:
gmp
2026-06-05 14:19:01 -04:00
parent 5a92ee9df3
commit b224bbe85a
2 changed files with 13 additions and 2 deletions
+7 -1
View File
@@ -300,11 +300,16 @@ func HandleCursorMove(delta int) {
// HandleKeyDown interprets keyboard events for navigation and editing.
// Receives both key.Event (as key.Name) and key.EditEvent from the main loop.
func HandleKeyDown(data any) {
log.Printf("HandleKeyDown: received data of type %T: %v", data, data)
switch v := data.(type) {
case key.EditEvent:
// Text input from IME / keyboard
log.Printf("HandleKeyDown: EditEvent text=%q", v.Text)
HandleInsert(v.Text)
if v.Text == "\b" || len(v.Text) == 0 {
HandleBackspace()
} else {
HandleInsert(v.Text)
}
case key.Name:
log.Printf("HandleKeyDown: name=%q", v)
switch v {
@@ -553,6 +558,7 @@ func HandleInsert(s string) {
// HandleBackspace removes the character before the cursor.
func HandleBackspace() {
log.Printf("HandleBackspace: CursorPosition=%d", TheState.Editor.CursorPosition)
pos := TheState.Editor.CursorPosition
if pos == 0 {
return