Fix race conditions with LSP requests that return buffers
* Avoid panic when registering a buffer that was previously open, and whose weak handle was still present in the open_buffers map. * Avoid releasing any buffers while a request is outstanding which could return a reference to a buffer. Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
17c9aa1819
commit
170487a528
3 changed files with 145 additions and 27 deletions
|
@ -4856,6 +4856,8 @@ mod tests {
|
|||
cx.background().simulate_random_delay().await;
|
||||
}
|
||||
|
||||
log::info!("Host done");
|
||||
|
||||
self.project = Some(project);
|
||||
(self, cx)
|
||||
}
|
||||
|
@ -4887,15 +4889,25 @@ mod tests {
|
|||
};
|
||||
|
||||
operations.set(operations.get() + 1);
|
||||
let project_path = worktree.read_with(&cx, |worktree, _| {
|
||||
let entry = worktree
|
||||
.entries(false)
|
||||
.filter(|e| e.is_file())
|
||||
.choose(&mut *rng.lock())
|
||||
.unwrap();
|
||||
(worktree.id(), entry.path.clone())
|
||||
});
|
||||
log::info!("Guest {}: opening path {:?}", guest_id, project_path);
|
||||
let (worktree_root_name, project_path) =
|
||||
worktree.read_with(&cx, |worktree, _| {
|
||||
let entry = worktree
|
||||
.entries(false)
|
||||
.filter(|e| e.is_file())
|
||||
.choose(&mut *rng.lock())
|
||||
.unwrap();
|
||||
(
|
||||
worktree.root_name().to_string(),
|
||||
(worktree.id(), entry.path.clone()),
|
||||
)
|
||||
});
|
||||
log::info!(
|
||||
"Guest {}: opening path in worktree {:?} {:?} {:?}",
|
||||
guest_id,
|
||||
project_path.0,
|
||||
worktree_root_name,
|
||||
project_path.1
|
||||
);
|
||||
let buffer = project
|
||||
.update(&mut cx, |project, cx| project.open_buffer(project_path, cx))
|
||||
.await
|
||||
|
@ -5062,6 +5074,8 @@ mod tests {
|
|||
cx.background().simulate_random_delay().await;
|
||||
}
|
||||
|
||||
log::info!("Guest {} done", guest_id);
|
||||
|
||||
self.project = Some(project);
|
||||
(self, cx)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue