From 7a85dd4e61f06317b7a4c40354e290d9eb60f9d3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 10 May 2019 14:24:50 +0200 Subject: [PATCH] after completion, set caret in next part at start instead of end of current part --- src/editor/model.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/editor/model.js b/src/editor/model.js index ed350b1337..fb3658a0be 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -124,18 +124,24 @@ export default class EditorModel { } _onAutoComplete = ({replacePart, caretOffset, close}) => { + let pos; if (replacePart) { this._replacePart(this._autoCompletePartIdx, replacePart); + let index = this._autoCompletePartIdx; + if (caretOffset === undefined) { + caretOffset = 0; + index += 1; + } + pos = new DocumentPosition(index, caretOffset); } - const index = this._autoCompletePartIdx; if (close) { this._autoComplete = null; this._autoCompletePartIdx = null; } - if (caretOffset === undefined) { - caretOffset = replacePart.text.length; - } - this._updateCallback(new DocumentPosition(index, caretOffset)); + // rerender even if editor contents didn't change + // to make sure the MessageEditor checks + // model.autoComplete being empty and closes it + this._updateCallback(pos); } /*