Merge pull request #3393 from matrix-org/bwindels/cider-fix-lastcaret
New composer: fix needing to push arrow-up twice after sending first message after switching to a room
This commit is contained in:
commit
6b104f6344
3 changed files with 26 additions and 7 deletions
|
@ -149,6 +149,9 @@ export default class EditorModel {
|
|||
|
||||
reset(serializedParts, caret, inputType) {
|
||||
this._parts = serializedParts.map(p => this._partCreator.deserializePart(p));
|
||||
if (!caret) {
|
||||
caret = this.getPositionAtEnd();
|
||||
}
|
||||
// close auto complete if open
|
||||
// this would happen when clearing the composer after sending
|
||||
// a message with the autocomplete still open
|
||||
|
|
|
@ -120,4 +120,17 @@ export default class DocumentPosition {
|
|||
const atEnd = offset >= lastPart.text.length;
|
||||
return new DocumentOffset(offset, atEnd);
|
||||
}
|
||||
|
||||
isAtEnd(model) {
|
||||
if (model.parts.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const lastPartIdx = model.parts.length - 1;
|
||||
const lastPart = model.parts[lastPartIdx];
|
||||
return this.index === lastPartIdx && this.offset === lastPart.text.length;
|
||||
}
|
||||
|
||||
isAtStart() {
|
||||
return this.index === 0 && this.offset === 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue