I made this change to addTextBlockHacks() which seems to solve my problem.
Hopefully this is not a bad idea!
addTextblockHacks() {
let lastChild = this.top.children[this.index - 1]
while (lastChild instanceof MarkViewDesc) lastChild = lastChild.children[lastChild.children.length - 1]
if(!lastChild || // Empty textblock
lastChild.node.type.name !== "hard_break") { // Don't double up on line breaks
if (!(lastChild instanceof TextViewDesc) ||
/\n$/.test(lastChild.node.text)) {
if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {
this.index++
} else {
let dom = document.createElement("br")
this.top.children.splice(this.index++, 0, new BRHackViewDesc(this.top, nothing, dom, null))
this.changed = true
}
}
}
}