Skip to content

Commit

Permalink
Fix double-space-to-period supppression on macOS Chrome
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marijnh committed Jan 9, 2025
1 parent 26af8ea commit 9c77d6d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/domobserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class EditContextManager {
selectionEnd: this.toContextPos(view.state.selection.main.head)
})
this.handlers.textupdate = e => {
let {anchor} = view.state.selection.main
let {anchor, head} = view.state.selection.main
let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd)
if (view.inputState.composing >= 0 && !this.composing)
this.composing = {contextBase: e.updateRangeStart, editorBase: from, drifted: false}
Expand All @@ -565,6 +565,9 @@ class EditContextManager {

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

this.pendingContextChange = change
if (!view.state.readOnly) {
Expand Down

0 comments on commit 9c77d6d

Please sign in to comment.