Avoid double handle-read in File::buffer_updated
This commit is contained in:
@@ -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
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user