Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15833 from atom/as-always-clear-composition-check…
Browse files Browse the repository at this point in the history
…points

Always revert to composition checkpoint, even if input is disabled
  • Loading branch information
Nathan Sobo committed Oct 6, 2017
1 parent c675c23 commit 2eb9361
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/text-editor-component.js
Expand Up @@ -1595,30 +1595,30 @@ class TextEditorComponent {
}

didTextInput (event) {
if (!this.isInputEnabled()) return

event.stopPropagation()

// WARNING: If we call preventDefault on the input of a space character,
// then the browser interprets the spacebar keypress as a page-down command,
// causing spaces to scroll elements containing editors. This is impossible
// to test.
if (event.data !== ' ') event.preventDefault()

if (this.compositionCheckpoint) {
this.props.model.revertToCheckpoint(this.compositionCheckpoint)
this.compositionCheckpoint = null
}

// If the input event is fired while the accented character menu is open it
// means that the user has chosen one of the accented alternatives. Thus, we
// will replace the original non accented character with the selected
// alternative.
if (this.accentedCharacterMenuIsOpen) {
this.props.model.selectLeft()
}
if (this.isInputEnabled()) {
event.stopPropagation()

// WARNING: If we call preventDefault on the input of a space character,
// then the browser interprets the spacebar keypress as a page-down command,
// causing spaces to scroll elements containing editors. This is impossible
// to test.
if (event.data !== ' ') event.preventDefault()

this.props.model.insertText(event.data, {groupUndo: true})
// If the input event is fired while the accented character menu is open it
// means that the user has chosen one of the accented alternatives. Thus, we
// will replace the original non accented character with the selected
// alternative.
if (this.accentedCharacterMenuIsOpen) {
this.props.model.selectLeft()
}

this.props.model.insertText(event.data, {groupUndo: true})
}
}

// We need to get clever to detect when the accented character menu is
Expand Down

0 comments on commit 2eb9361

Please sign in to comment.