mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-09 10:56:20 +00:00
Avoid retaining project in randomized test while LSP request is outstanding
This commit is contained in:
parent
1a9ff2420e
commit
2c84b74126
1 changed files with 33 additions and 35 deletions
|
@ -197,13 +197,17 @@ async fn test_random_collaboration(
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
guest_snapshot.entries(false).collect::<Vec<_>>(),
|
guest_snapshot.entries(false).collect::<Vec<_>>(),
|
||||||
host_snapshot.entries(false).collect::<Vec<_>>(),
|
host_snapshot.entries(false).collect::<Vec<_>>(),
|
||||||
"{} has different snapshot than the host for worktree {} ({:?}) and project {:?}",
|
"{} has different snapshot than the host for worktree {:?} and project {:?}",
|
||||||
|
client.username,
|
||||||
|
host_snapshot.abs_path(),
|
||||||
|
host_project.read_with(host_cx, |project, _| project.remote_id())
|
||||||
|
);
|
||||||
|
assert_eq!(guest_snapshot.scan_id(), host_snapshot.scan_id(),
|
||||||
|
"{} has different scan id than the host for worktree {:?} and project {:?}",
|
||||||
client.username,
|
client.username,
|
||||||
id,
|
|
||||||
host_snapshot.abs_path(),
|
host_snapshot.abs_path(),
|
||||||
host_project.read_with(host_cx, |project, _| project.remote_id())
|
host_project.read_with(host_cx, |project, _| project.remote_id())
|
||||||
);
|
);
|
||||||
assert_eq!(guest_snapshot.scan_id(), host_snapshot.scan_id());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -812,39 +816,32 @@ async fn apply_client_operation(
|
||||||
if detach { ", detaching" } else { ", awaiting" }
|
if detach { ", detaching" } else { ", awaiting" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
use futures::{FutureExt as _, TryFutureExt as _};
|
||||||
let offset = buffer.read_with(cx, |b, _| b.clip_offset(offset, Bias::Left));
|
let offset = buffer.read_with(cx, |b, _| b.clip_offset(offset, Bias::Left));
|
||||||
let request = match kind {
|
let request = cx.foreground().spawn(project.update(cx, |project, cx| {
|
||||||
LspRequestKind::Rename => cx.spawn(|mut cx| async move {
|
match kind {
|
||||||
project
|
LspRequestKind::Rename => project
|
||||||
.update(&mut cx, |p, cx| p.prepare_rename(buffer, offset, cx))
|
.prepare_rename(buffer, offset, cx)
|
||||||
.await?;
|
.map_ok(|_| ())
|
||||||
anyhow::Ok(())
|
.boxed(),
|
||||||
}),
|
LspRequestKind::Completion => project
|
||||||
LspRequestKind::Completion => cx.spawn(|mut cx| async move {
|
.completions(&buffer, offset, cx)
|
||||||
project
|
.map_ok(|_| ())
|
||||||
.update(&mut cx, |p, cx| p.completions(&buffer, offset, cx))
|
.boxed(),
|
||||||
.await?;
|
LspRequestKind::CodeAction => project
|
||||||
Ok(())
|
.code_actions(&buffer, offset..offset, cx)
|
||||||
}),
|
.map_ok(|_| ())
|
||||||
LspRequestKind::CodeAction => cx.spawn(|mut cx| async move {
|
.boxed(),
|
||||||
project
|
LspRequestKind::Definition => project
|
||||||
.update(&mut cx, |p, cx| p.code_actions(&buffer, offset..offset, cx))
|
.definition(&buffer, offset, cx)
|
||||||
.await?;
|
.map_ok(|_| ())
|
||||||
Ok(())
|
.boxed(),
|
||||||
}),
|
LspRequestKind::Highlights => project
|
||||||
LspRequestKind::Definition => cx.spawn(|mut cx| async move {
|
.document_highlights(&buffer, offset, cx)
|
||||||
project
|
.map_ok(|_| ())
|
||||||
.update(&mut cx, |p, cx| p.definition(&buffer, offset, cx))
|
.boxed(),
|
||||||
.await?;
|
}
|
||||||
Ok(())
|
}));
|
||||||
}),
|
|
||||||
LspRequestKind::Highlights => cx.spawn(|mut cx| async move {
|
|
||||||
project
|
|
||||||
.update(&mut cx, |p, cx| p.document_highlights(&buffer, offset, cx))
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
if detach {
|
if detach {
|
||||||
request.detach();
|
request.detach();
|
||||||
} else {
|
} else {
|
||||||
|
@ -873,6 +870,7 @@ async fn apply_client_operation(
|
||||||
let search = project.update(cx, |project, cx| {
|
let search = project.update(cx, |project, cx| {
|
||||||
project.search(SearchQuery::text(query, false, false), cx)
|
project.search(SearchQuery::text(query, false, false), cx)
|
||||||
});
|
});
|
||||||
|
drop(project);
|
||||||
let search = cx.background().spawn(async move {
|
let search = cx.background().spawn(async move {
|
||||||
search
|
search
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Reference in a new issue