mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Request code actions inside of task to avoid spamming the LSP
This commit is contained in:
parent
ae75648f0d
commit
90576cf32f
1 changed files with 21 additions and 21 deletions
|
@ -1511,28 +1511,28 @@ impl Project {
|
||||||
return Task::ready(Ok(Default::default()));
|
return Task::ready(Ok(Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let actions =
|
let lsp_range = lsp::Range::new(
|
||||||
lang_server.request::<lsp::request::CodeActionRequest>(lsp::CodeActionParams {
|
range.start.to_point_utf16(buffer).to_lsp_position(),
|
||||||
text_document: lsp::TextDocumentIdentifier::new(
|
range.end.to_point_utf16(buffer).to_lsp_position(),
|
||||||
lsp::Url::from_file_path(buffer_abs_path).unwrap(),
|
);
|
||||||
),
|
|
||||||
range: lsp::Range::new(
|
|
||||||
range.start.to_point_utf16(buffer).to_lsp_position(),
|
|
||||||
range.end.to_point_utf16(buffer).to_lsp_position(),
|
|
||||||
),
|
|
||||||
work_done_progress_params: Default::default(),
|
|
||||||
partial_result_params: Default::default(),
|
|
||||||
context: lsp::CodeActionContext {
|
|
||||||
diagnostics: Default::default(),
|
|
||||||
only: Some(vec![
|
|
||||||
lsp::CodeActionKind::QUICKFIX,
|
|
||||||
lsp::CodeActionKind::REFACTOR,
|
|
||||||
lsp::CodeActionKind::REFACTOR_EXTRACT,
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
cx.foreground().spawn(async move {
|
cx.foreground().spawn(async move {
|
||||||
Ok(actions
|
Ok(lang_server
|
||||||
|
.request::<lsp::request::CodeActionRequest>(lsp::CodeActionParams {
|
||||||
|
text_document: lsp::TextDocumentIdentifier::new(
|
||||||
|
lsp::Url::from_file_path(buffer_abs_path).unwrap(),
|
||||||
|
),
|
||||||
|
range: lsp_range,
|
||||||
|
work_done_progress_params: Default::default(),
|
||||||
|
partial_result_params: Default::default(),
|
||||||
|
context: lsp::CodeActionContext {
|
||||||
|
diagnostics: Default::default(),
|
||||||
|
only: Some(vec![
|
||||||
|
lsp::CodeActionKind::QUICKFIX,
|
||||||
|
lsp::CodeActionKind::REFACTOR,
|
||||||
|
lsp::CodeActionKind::REFACTOR_EXTRACT,
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
})
|
||||||
.await?
|
.await?
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
Loading…
Reference in a new issue