diff --git a/src/js/editor/editor.js b/src/js/editor/editor.js index 838c04a9a..17b68317f 100644 --- a/src/js/editor/editor.js +++ b/src/js/editor/editor.js @@ -462,7 +462,7 @@ class Editor { }); this.rerender(); if (currentRange) { - this.selectRange(currentRange); + this.selectRange(currentRange.move(DIRECTION.FORWARD)); } this.runCallbacks(CALLBACK_QUEUES.DID_REPARSE); diff --git a/tests/acceptance/editor-reparse-test.js b/tests/acceptance/editor-reparse-test.js index e63639c7f..a1c36b3ab 100644 --- a/tests/acceptance/editor-reparse-test.js +++ b/tests/acceptance/editor-reparse-test.js @@ -239,6 +239,29 @@ test('inserting text into text node on left/right of atom is reparsed correctly' }); }); +test('inserting a single character into an empty section moves the cursor forward', (assert) => { + let done = assert.async(); + let expected; + editor = Helpers.mobiledoc.renderInto(editorElement, ({post, markupSection, marker}) => { + expected = post([ + markupSection('p', [marker('Z')]), + ]); + + return post([markupSection('p', [])]); + }, editorOptions); + + let node = editorElement.firstChild.firstChild; + node.textContent = 'Z'; + + Helpers.wait(() => { + assert.postIsSimilar(editor.post, expected); + assert.equal(editor.range.head.offset, 1); + assert.equal(editor.range.tail.offset, 1); + + done(); + }); +}); + test('mutation inside card element does not cause reparse', (assert) => { let done = assert.async(); let parseCount = 0;