mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Remove waiting for edits when handling code action RPC requests
Add code actions to the randomized integration test Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
41ba980c9b
commit
3315750361
@ -2433,11 +2433,10 @@ impl Project {
|
|||||||
.and_then(|shared_buffers| shared_buffers.get(&envelope.payload.buffer_id).cloned())
|
.and_then(|shared_buffers| shared_buffers.get(&envelope.payload.buffer_id).cloned())
|
||||||
.ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))
|
.ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))
|
||||||
})?;
|
})?;
|
||||||
buffer
|
let version = buffer.read_with(&cx, |buffer, _| buffer.version());
|
||||||
.update(&mut cx, |buffer, _| {
|
if !version.observed(start.timestamp) || !version.observed(end.timestamp) {
|
||||||
buffer.wait_for_version([start.timestamp, end.timestamp].into_iter().collect())
|
Err(anyhow!("code action request references unreceived edits"))?;
|
||||||
})
|
}
|
||||||
.await;
|
|
||||||
let code_actions = this.update(&mut cx, |this, cx| {
|
let code_actions = this.update(&mut cx, |this, cx| {
|
||||||
Ok::<_, anyhow::Error>(this.code_actions(&buffer, start..end, cx))
|
Ok::<_, anyhow::Error>(this.code_actions(&buffer, start..end, cx))
|
||||||
})?;
|
})?;
|
||||||
|
@ -3622,6 +3622,15 @@ mod tests {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}]))
|
}]))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fake_server.handle_request::<lsp::request::CodeActionRequest, _>(|_| {
|
||||||
|
Some(vec![lsp::CodeActionOrCommand::CodeAction(
|
||||||
|
lsp::CodeAction {
|
||||||
|
title: "the-code-action".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)])
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Arc::get_mut(&mut host_lang_registry)
|
Arc::get_mut(&mut host_lang_registry)
|
||||||
@ -4180,7 +4189,7 @@ mod tests {
|
|||||||
drop(buffer);
|
drop(buffer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
10..=19 => {
|
10..=14 => {
|
||||||
project
|
project
|
||||||
.update(&mut cx, |project, cx| {
|
.update(&mut cx, |project, cx| {
|
||||||
log::info!(
|
log::info!(
|
||||||
@ -4193,6 +4202,19 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.expect("completion request failed");
|
.expect("completion request failed");
|
||||||
}
|
}
|
||||||
|
15..=19 => {
|
||||||
|
project
|
||||||
|
.update(&mut cx, |project, cx| {
|
||||||
|
log::info!(
|
||||||
|
"Guest {}: requesting code actions for buffer {:?}",
|
||||||
|
guest_id,
|
||||||
|
buffer.read(cx).file().unwrap().full_path(cx)
|
||||||
|
);
|
||||||
|
project.code_actions(&buffer, 0..0, cx)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("completion request failed");
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
buffer.update(&mut cx, |buffer, cx| {
|
buffer.update(&mut cx, |buffer, cx| {
|
||||||
log::info!(
|
log::info!(
|
||||||
|
Loading…
Reference in New Issue
Block a user