Operational-Transformation/ot.js

Exception when trying to compose lastOperation.

mikelehen opened this issue · 1 comments

Repro:

  1. Add a character ('X') in first editor.
  2. In a second editor, add a character some place after the 'X'.
  3. Add a character 'Y' directly after 'X' in the first editor.

Result:
Uncaught Error: The base length of the second operation has to be the target length of the first operation
from "this.lastOperation = this.lastOperation.compose(textOperation);" in editor-client.js

I believe the problem is lastOperation isn't being transformed when we get new remote operations.

You're correct. However, transforming lastOperation is non-trivial, as it would require a different kind of transform that exchanges operations that happened after each other. I ended up writing a method that decides whether two already inverted operations should be composed in the undo stack, therefore eliminating the need for lastOperation.