mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
fix: textchange can be both delete and insert
This commit is contained in:
parent
a5502d1f1f
commit
e43105b919
1 changed files with 6 additions and 4 deletions
|
@ -100,11 +100,13 @@ impl ControllerWorker<TextChange> for BufferWorker {
|
||||||
let agent_id = oplog.get_or_create_agent_id(&self.user_id.to_string());
|
let agent_id = oplog.get_or_create_agent_id(&self.user_id.to_string());
|
||||||
let last_ver = oplog.local_version();
|
let last_ver = oplog.local_version();
|
||||||
|
|
||||||
|
if change.is_delete() {
|
||||||
|
branch.delete_without_content(&mut oplog, 1, change.span());
|
||||||
|
}
|
||||||
|
|
||||||
if change.is_insert() {
|
if change.is_insert() {
|
||||||
branch.insert(&mut oplog, agent_id, change.start as usize, &change.content)
|
branch.insert(&mut oplog, agent_id, change.start as usize, &change.content);
|
||||||
} else if change.is_delete() {
|
}
|
||||||
branch.delete_without_content(&mut oplog, 1, change.span())
|
|
||||||
} else { continue; };
|
|
||||||
|
|
||||||
tx.send(Operation { data: oplog.encode_from(Default::default(), &last_ver) }).await
|
tx.send(Operation { data: oplog.encode_from(Default::default(), &last_ver) }).await
|
||||||
.unwrap_or_warn("failed to send change!");
|
.unwrap_or_warn("failed to send change!");
|
||||||
|
|
Loading…
Reference in a new issue