Don't show conflict indicator on remote buffer after a reload
This commit is contained in:
parent
4372fe1ed0
commit
f859d444ff
6 changed files with 201 additions and 17 deletions
|
@ -299,6 +299,7 @@ impl Project {
|
|||
),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_update_buffer),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_update_buffer_file),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_buffer_reloaded),
|
||||
client.subscribe_to_entity(remote_id, cx, Self::handle_buffer_saved),
|
||||
],
|
||||
client,
|
||||
|
@ -1694,6 +1695,37 @@ impl Project {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_buffer_reloaded(
|
||||
&mut self,
|
||||
envelope: TypedEnvelope<proto::BufferReloaded>,
|
||||
_: Arc<Client>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Result<()> {
|
||||
let payload = envelope.payload.clone();
|
||||
let buffer = self
|
||||
.open_buffers
|
||||
.get(&(payload.buffer_id as usize))
|
||||
.and_then(|buf| {
|
||||
if let OpenBuffer::Loaded(buffer) = buf {
|
||||
buffer.upgrade(cx)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
if let Some(buffer) = buffer {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
let version = payload.version.try_into()?;
|
||||
let mtime = payload
|
||||
.mtime
|
||||
.ok_or_else(|| anyhow!("missing mtime"))?
|
||||
.into();
|
||||
buffer.did_reload(version, mtime, cx);
|
||||
Result::<_, anyhow::Error>::Ok(())
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn match_paths<'a>(
|
||||
&self,
|
||||
query: &'a str,
|
||||
|
|
|
@ -1520,6 +1520,28 @@ impl language::LocalFile for File {
|
|||
cx.background()
|
||||
.spawn(async move { fs.load(&abs_path).await })
|
||||
}
|
||||
|
||||
fn buffer_reloaded(
|
||||
&self,
|
||||
buffer_id: u64,
|
||||
version: &clock::Global,
|
||||
mtime: SystemTime,
|
||||
cx: &mut MutableAppContext,
|
||||
) {
|
||||
let worktree = self.worktree.read(cx).as_local().unwrap();
|
||||
if let Some(project_id) = worktree.share.as_ref().map(|share| share.project_id) {
|
||||
let rpc = worktree.client.clone();
|
||||
let message = proto::BufferReloaded {
|
||||
project_id,
|
||||
buffer_id,
|
||||
version: version.into(),
|
||||
mtime: Some(mtime.into()),
|
||||
};
|
||||
cx.background()
|
||||
.spawn(async move { rpc.send(message).await })
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl File {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue