mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
fix: proper translation from dt::Operation to Textchange
Co-authored-by: alemi <me@alemi.dev>
This commit is contained in:
parent
97b7504098
commit
c58d1db58b
1 changed files with 21 additions and 5 deletions
|
@ -148,11 +148,27 @@ impl ControllerWorker<TextChange> for BufferWorker {
|
||||||
Some(crate::hash(branch.content().to_string()))
|
Some(crate::hash(branch.content().to_string()))
|
||||||
} else { None };
|
} else { None };
|
||||||
|
|
||||||
let tc = crate::api::change::TextChange {
|
let tc = match dtop.kind {
|
||||||
start: dtop.start() as u32,
|
diamond_types::list::operation::OpKind::Ins => {
|
||||||
end: dtop.end() as u32,
|
if dtop.end() - dtop.start() != dtop.content_as_str().unwrap_or_default().len() {
|
||||||
content: dtop.content_as_str().unwrap_or_default().to_string(),
|
tracing::error!("[?!?!] Insert span differs from effective content len (TODO remove this error after a bit)");
|
||||||
hash
|
}
|
||||||
|
crate::api::change::TextChange {
|
||||||
|
start: dtop.start() as u32,
|
||||||
|
end: dtop.start() as u32,
|
||||||
|
content: dtop.content_as_str().unwrap_or_default().to_string(),
|
||||||
|
hash
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
diamond_types::list::operation::OpKind::Del => {
|
||||||
|
crate::api::change::TextChange {
|
||||||
|
start: dtop.start() as u32,
|
||||||
|
end: dtop.end() as u32,
|
||||||
|
content: dtop.content_as_str().unwrap_or_default().to_string(),
|
||||||
|
hash
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
tx.send((new_local_v, tc)).unwrap_or_warn("could not update ops channel -- is controller dead?");
|
tx.send((new_local_v, tc)).unwrap_or_warn("could not update ops channel -- is controller dead?");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue