after completion, set caret in next part at start
instead of end of current part
This commit is contained in:
parent
2c3453d307
commit
7a85dd4e61
1 changed files with 11 additions and 5 deletions
|
@ -124,18 +124,24 @@ export default class EditorModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
_onAutoComplete = ({replacePart, caretOffset, close}) => {
|
||||||
|
let pos;
|
||||||
if (replacePart) {
|
if (replacePart) {
|
||||||
this._replacePart(this._autoCompletePartIdx, 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) {
|
if (close) {
|
||||||
this._autoComplete = null;
|
this._autoComplete = null;
|
||||||
this._autoCompletePartIdx = null;
|
this._autoCompletePartIdx = null;
|
||||||
}
|
}
|
||||||
if (caretOffset === undefined) {
|
// rerender even if editor contents didn't change
|
||||||
caretOffset = replacePart.text.length;
|
// to make sure the MessageEditor checks
|
||||||
}
|
// model.autoComplete being empty and closes it
|
||||||
this._updateCallback(new DocumentPosition(index, caretOffset));
|
this._updateCallback(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue