-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong deltas? #98
Comments
Deltas in its current form was designed to reduce the number of operations, which right now is just two: insert and retain. It always describes the whole document so it's not the most compact format (though usually its just a two extra retain operations). The third instruction you're seeing is saying delete the first two letters and insert 'aaa'. This result in the same output but the optimal delta should be insert an 'a' at the 2nd position. This is due to a bad optimization heuristic we are using so we'll plan to fix this in a future release. The Delta interface is still being finalized so we can still consider adding a delete operation or make deltas easier to read/work with. |
I thought I should process ops in the order received so doesn't it say insert 'aaa', delete the first two letters? Should I first process RetainOp { start=2, end=3 } and only than InsertOp { value="aaa" }?
Don't you mean that it should be insert an 'a' at the 3rd position? ot.js uses a very compact ops format ["a"] // insert "a" in empty document
[1, "a"] // retain one char and insert "a"
[1, -1] // retain one char and delete the second char It also gives you the baseLength so you could make sure two deltas are working on the same initial document. http://ot.substance.io/visualization/ Will you consider using the same format? It seems like a very compact format that is easy to work with in code. Can you explain how OT should work with the current format quill use? [ InsertOp { value="aaa" }, RetainOp { start=2, end=3 } ] The reason I'm asking is I tested the GoInstant quill demo and it seems to work worst than ot.js demo. |
Yes this is more specifically correct. I reversed so there's no ambiguity over which two letters you are deleting.
Yes.
Sure all reasonable ideas are worth considering. It's worth noting that Deltas are objects with useful methods so it will always do worse if we want sensible variable names. Either way the Delta interface is again not finalized and probably not optimal.
Deltas describe the whole document so you start with index 0. You see insert 'aaa' so you insert 'aaa' at index 0. You see retain 2,3 and note 2 > your current index of 0 so you delete characters 0-2 from the original document. You advance to index 3 (keeping one character). With no more instructions if index 3 was not the last index of the document, you delete the rest of the document. You can avoid having to do this yourself most of the time with Delta.apply. |
I made another test. [ InsertOp { value="123" }, RetainOp { start=2, end=3 } ] Following you instructions: Can you please explain how it works in this case? I tested with a longer string "123456789". The last delta always have insert op with the complete string. Is this the non optimal representation you was referring to? In ot.js the last delta will be just [8,"9"]. |
This is why I switched the instructions around earlier. The original character 0-2 is now index 3-5 since a 3 letter string just got inserted. So after step 2 you should have 123.
Yes |
I don't understand how it should work. |
Let's start with 'ab' instead of '12' to avoid confusion with inserted text.
|
I'm testing demo/index.html with FF 29 and IE11.
When writing "aaa" the deltas I'm getting are:
Why two ops are produced for the first "a"?
Doesn't InsertOp {value="a"} already have all the info we need?
Shouldn't we get RetainOp only when skipping some text?
Why the last step produces an InsertOp {value="aaa"} although I only added a single "a" after the previous op?
In the last RetainOp start=2 and end=3 which is not consistent with previous ops.
When I enter "ab" I'm getting the following deltas:
When entering "ab" I expected to get the same ops like when entering "aa" but for some reason the second ops is different.
Will you consider adding a DeleteOp?
It will make operations much easier to work with.
Did you remove it to save bandwidth when synching?
Thanks
The text was updated successfully, but these errors were encountered: