Skip to content

Commit

Permalink
Allow Android enter to eat a space at the end of the line
Browse files Browse the repository at this point in the history
FIX: Properly recognize Android GBoard enter presses that strip a space at
the end of the line as enter.

Closes codemirror/dev#1312
  • Loading branch information
marijnh committed Feb 19, 2024
1 parent 06e3f47 commit fc1d11f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/domchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ export function applyDOMChange(view: EditorView, domChange: DOMChange): boolean
// events and the pendingAndroidKey mechanism, but that's not
// reliable in all situations.)
if (browser.android &&
((change.from == sel.from && change.to == sel.to &&
((change.to == sel.to &&
// GBoard will sometimes remove a space it just inserted
// after a completion when you press enter
(change.from == sel.from || change.from == sel.from - 1 && view.state.sliceDoc(change.from, sel.from) == " ") &&
change.insert.length == 1 && change.insert.lines == 2 &&
dispatchKey(view.contentDOM, "Enter", 13)) ||
((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||
Expand Down

0 comments on commit fc1d11f

Please sign in to comment.