Avoid double handle-read in File::buffer_updated

This commit is contained in:
Max Brunsfeld
2021-06-25 17:21:42 -07:00
parent 60ee97be24
commit e2b9ab500f
2 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -1339,7 +1339,7 @@ impl Buffer {
#[cfg(not(test))]
pub fn send_operation(&mut self, operation: Operation, cx: &mut ModelContext<Self>) {
if let Some(file) = &self.file {
file.buffer_updated(cx.handle(), operation, cx.as_mut());
file.buffer_updated(self.remote_id, operation, cx.as_mut());
}
}
+6 -7
View File
@@ -933,13 +933,7 @@ impl File {
})
}
pub fn buffer_updated(
&self,
buffer: ModelHandle<Buffer>,
operation: Operation,
cx: &mut MutableAppContext,
) {
let buffer_id = buffer.read(cx).remote_id();
pub fn buffer_updated(&self, buffer_id: u64, operation: Operation, cx: &mut MutableAppContext) {
self.worktree.update(cx, |worktree, cx| {
if let Some((rpc, remote_id)) = match worktree {
Worktree::Local(worktree) => worktree.rpc.clone(),
@@ -1883,6 +1877,11 @@ mod remote {
}) {
log::error!("error applying buffer operations {}", error);
}
} else {
log::error!(
"invalid buffer {} in update buffer message",
message.buffer_id
);
}
Ok(())
}