Skip to content

Commit ee2c8aa

Browse files
committed
Limit EditContext change-while-composition trick
FIX: Work around an issue with Chrome's `EditContext` that shows up when using autocompletion while composing with Samsung's virtual Android keyboard. Issue codemirror/dev#1504
1 parent 4bdec39 commit ee2c8aa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/domobserver.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,11 @@ class EditContextManager {
673673
}
674674

675675
update(update: ViewUpdate) {
676-
let reverted = this.pendingContextChange
677-
if (this.composing && (this.composing.drifted || update.transactions.some(
678-
tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to)))) {
676+
let reverted = this.pendingContextChange, startSel = update.startState.selection.main
677+
if (this.composing &&
678+
(this.composing.drifted ||
679+
(!update.changes.touchesRange(startSel.from, startSel.to) &&
680+
update.transactions.some(tr => !tr.isUserEvent("input.type") && tr.changes.touchesRange(this.from, this.to))))) {
679681
this.composing.drifted = true
680682
this.composing.editorBase = update.changes.mapPos(this.composing.editorBase)
681683
} else if (!this.applyEdits(update) || !this.rangeIsValid(update.state)) {

0 commit comments

Comments
 (0)