Skip to content

Commit 9c77d6d

Browse files
committed
Fix double-space-to-period supppression on macOS Chrome
FIX: Make sure macOS double-space-to-period conversions are properly suppressed. See https://discuss.codemirror.net/t/dot-being-added-when-pressing-space-repeatedly/3899/13
1 parent 26af8ea commit 9c77d6d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/domobserver.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class EditContextManager {
553553
selectionEnd: this.toContextPos(view.state.selection.main.head)
554554
})
555555
this.handlers.textupdate = e => {
556-
let {anchor} = view.state.selection.main
556+
let {anchor, head} = view.state.selection.main
557557
let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd)
558558
if (view.inputState.composing >= 0 && !this.composing)
559559
this.composing = {contextBase: e.updateRangeStart, editorBase: from, drifted: false}
@@ -565,6 +565,9 @@ class EditContextManager {
565565

566566
// Edit contexts sometimes fire empty changes
567567
if (change.from == change.to && !change.insert.length) return
568+
if ((browser.mac || browser.android) && change.from == head - 1 &&
569+
/^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
570+
change = {from, to, insert: Text.of([e.text.replace(".", " ")])}
568571

569572
this.pendingContextChange = change
570573
if (!view.state.readOnly) {

0 commit comments

Comments
 (0)