Serialize buffer in terms of operations rather than state

This is required because, after joining, we want to be able to refer
to operations that have happened prior to joining, which are not
captured by the state. There is probably a way of reconstructing operations
from the state, but that seems unnecessary and we've already talked about
wanting to have the server store operations rather than state once we start
persisting worktrees.
This commit is contained in:
Antonio Scandurra 2022-02-08 14:50:47 +01:00
parent dca974c7d4
commit 624eb5907e
6 changed files with 146 additions and 170 deletions

View file

@ -550,12 +550,12 @@ fn test_concurrent_edits() {
let buf3_op = buffer3.edit(vec![5..6], "56");
assert_eq!(buffer3.text(), "abcde56");
buffer1.apply_op(Operation::Edit(buf2_op.clone())).unwrap();
buffer1.apply_op(Operation::Edit(buf3_op.clone())).unwrap();
buffer2.apply_op(Operation::Edit(buf1_op.clone())).unwrap();
buffer2.apply_op(Operation::Edit(buf3_op.clone())).unwrap();
buffer3.apply_op(Operation::Edit(buf1_op.clone())).unwrap();
buffer3.apply_op(Operation::Edit(buf2_op.clone())).unwrap();
buffer1.apply_op(buf2_op.clone()).unwrap();
buffer1.apply_op(buf3_op.clone()).unwrap();
buffer2.apply_op(buf1_op.clone()).unwrap();
buffer2.apply_op(buf3_op.clone()).unwrap();
buffer3.apply_op(buf1_op.clone()).unwrap();
buffer3.apply_op(buf2_op.clone()).unwrap();
assert_eq!(buffer1.text(), "a12c34e56");
assert_eq!(buffer2.text(), "a12c34e56");