Include buffer's deferred ops when computing has_buffered_operations
This commit is contained in:
parent
720056d0db
commit
abdfdcdabf
2 changed files with 25 additions and 10 deletions
|
@ -405,12 +405,17 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub fn has_buffered_operations(&self) -> bool {
|
pub fn has_buffered_operations(&self, cx: &AppContext) -> bool {
|
||||||
self.buffers_state
|
self.buffers_state
|
||||||
.borrow()
|
.borrow()
|
||||||
.open_buffers
|
.open_buffers
|
||||||
.values()
|
.values()
|
||||||
.any(|buffer| matches!(buffer, OpenBuffer::Loading(_)))
|
.any(|buffer| match buffer {
|
||||||
|
OpenBuffer::Loaded(buffer) => buffer
|
||||||
|
.upgrade(cx)
|
||||||
|
.map_or(false, |buffer| buffer.read(cx).deferred_ops_len() > 0),
|
||||||
|
OpenBuffer::Loading(_) => true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
|
|
@ -4368,9 +4368,9 @@ mod tests {
|
||||||
.project
|
.project
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.read_with(guest_cx, |project, _| {
|
.read_with(guest_cx, |project, cx| {
|
||||||
assert!(
|
assert!(
|
||||||
!project.has_buffered_operations(),
|
!project.has_buffered_operations(cx),
|
||||||
"guest {} has buffered operations ",
|
"guest {} has buffered operations ",
|
||||||
guest_id,
|
guest_id,
|
||||||
);
|
);
|
||||||
|
@ -4382,7 +4382,7 @@ mod tests {
|
||||||
project
|
project
|
||||||
.shared_buffer(guest_client.peer_id, buffer_id)
|
.shared_buffer(guest_client.peer_id, buffer_id)
|
||||||
.expect(&format!(
|
.expect(&format!(
|
||||||
"host doest not have buffer for guest:{}, peer:{}, id:{}",
|
"host does not have buffer for guest:{}, peer:{}, id:{}",
|
||||||
guest_id, guest_client.peer_id, buffer_id
|
guest_id, guest_client.peer_id, buffer_id
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
@ -4867,9 +4867,19 @@ mod tests {
|
||||||
project_path.1
|
project_path.1
|
||||||
);
|
);
|
||||||
let buffer = project
|
let buffer = project
|
||||||
.update(&mut cx, |project, cx| project.open_buffer(project_path, cx))
|
.update(&mut cx, |project, cx| {
|
||||||
|
project.open_buffer(project_path.clone(), cx)
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
log::info!(
|
||||||
|
"Guest {}: path in worktree {:?} {:?} {:?} opened with buffer id {:?}",
|
||||||
|
guest_id,
|
||||||
|
project_path.0,
|
||||||
|
worktree_root_name,
|
||||||
|
project_path.1,
|
||||||
|
buffer.read_with(&cx, |buffer, _| buffer.remote_id())
|
||||||
|
);
|
||||||
self.buffers.insert(buffer.clone());
|
self.buffers.insert(buffer.clone());
|
||||||
buffer
|
buffer
|
||||||
} else {
|
} else {
|
||||||
|
@ -4958,7 +4968,7 @@ mod tests {
|
||||||
save.await;
|
save.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
40..=45 => {
|
40..=44 => {
|
||||||
let prepare_rename = project.update(&mut cx, |project, cx| {
|
let prepare_rename = project.update(&mut cx, |project, cx| {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Guest {}: preparing rename for buffer {:?}",
|
"Guest {}: preparing rename for buffer {:?}",
|
||||||
|
@ -4978,10 +4988,10 @@ mod tests {
|
||||||
prepare_rename.await;
|
prepare_rename.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
46..=49 => {
|
45..=49 => {
|
||||||
let definitions = project.update(&mut cx, |project, cx| {
|
let definitions = project.update(&mut cx, |project, cx| {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Guest {}: requesting defintions for buffer {:?}",
|
"Guest {}: requesting definitions for buffer {:?}",
|
||||||
guest_id,
|
guest_id,
|
||||||
buffer.read(cx).file().unwrap().full_path(cx)
|
buffer.read(cx).file().unwrap().full_path(cx)
|
||||||
);
|
);
|
||||||
|
@ -4999,7 +5009,7 @@ mod tests {
|
||||||
.extend(definitions.await.into_iter().map(|loc| loc.buffer));
|
.extend(definitions.await.into_iter().map(|loc| loc.buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50..=55 => {
|
50..=54 => {
|
||||||
let highlights = project.update(&mut cx, |project, cx| {
|
let highlights = project.update(&mut cx, |project, cx| {
|
||||||
log::info!(
|
log::info!(
|
||||||
"Guest {}: requesting highlights for buffer {:?}",
|
"Guest {}: requesting highlights for buffer {:?}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue