From 2c3453d307c3f55d805ea6025cfa55ca6db48a0f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 9 May 2019 20:37:45 +0200 Subject: [PATCH] put caret after replaced part if no caretOffset is given by autocomplete --- src/editor/autocomplete.js | 4 ++-- src/editor/model.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/editor/autocomplete.js b/src/editor/autocomplete.js index a322d5e6ce..d2f73b1dff 100644 --- a/src/editor/autocomplete.js +++ b/src/editor/autocomplete.js @@ -28,7 +28,7 @@ export default class AutocompleteWrapperModel { this._getAutocompleterComponent().onEscape(e); this._updateCallback({ replacePart: new PlainPart(this._queryPart.text), - replaceCaret: this._queryOffset, + caretOffset: this._queryOffset, close: true, }); } @@ -61,7 +61,7 @@ export default class AutocompleteWrapperModel { if (!completion) { this._updateCallback({ replacePart: this._queryPart, - replaceCaret: this._queryOffset, + caretOffset: this._queryOffset, }); } else { this._updateCallback({ diff --git a/src/editor/model.js b/src/editor/model.js index e7284da005..ed350b1337 100644 --- a/src/editor/model.js +++ b/src/editor/model.js @@ -123,7 +123,7 @@ export default class EditorModel { } } - _onAutoComplete = ({replacePart, replaceCaret, close}) => { + _onAutoComplete = ({replacePart, caretOffset, close}) => { if (replacePart) { this._replacePart(this._autoCompletePartIdx, replacePart); } @@ -132,7 +132,10 @@ export default class EditorModel { this._autoComplete = null; this._autoCompletePartIdx = null; } - this._updateCallback(new DocumentPosition(index, replaceCaret)); + if (caretOffset === undefined) { + caretOffset = replacePart.text.length; + } + this._updateCallback(new DocumentPosition(index, caretOffset)); } /*