mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 13:10:54 +00:00
Fix clipping when using label-only completions
This commit is contained in:
parent
ba009724dd
commit
fe8e06e781
1 changed files with 15 additions and 11 deletions
|
@ -2373,13 +2373,6 @@ impl Project {
|
|||
};
|
||||
|
||||
cx.spawn(|_, cx| async move {
|
||||
let clipped_position = source_buffer_handle
|
||||
.read_with(&cx, |this, _| this.clip_point_utf16(position, Bias::Left));
|
||||
if clipped_position != position {
|
||||
log::info!("Completion position out of date");
|
||||
return Ok(Default::default());
|
||||
}
|
||||
|
||||
let completions = lang_server
|
||||
.request::<lsp::request::Completion>(lsp::CompletionParams {
|
||||
text_document_position: lsp::TextDocumentPositionParams::new(
|
||||
|
@ -2412,10 +2405,21 @@ impl Project {
|
|||
Some(lsp::CompletionTextEdit::Edit(edit)) => {
|
||||
(range_from_lsp(edit.range), edit.new_text.clone())
|
||||
}
|
||||
None => (
|
||||
this.common_prefix_at(position, &lsp_completion.label),
|
||||
lsp_completion.label.clone(),
|
||||
),
|
||||
None => {
|
||||
let clipped_position =
|
||||
this.clip_point_utf16(position, Bias::Left);
|
||||
if position != clipped_position {
|
||||
log::info!("completion out of expected range");
|
||||
return None;
|
||||
}
|
||||
(
|
||||
this.common_prefix_at(
|
||||
clipped_position,
|
||||
&lsp_completion.label,
|
||||
),
|
||||
lsp_completion.label.clone(),
|
||||
)
|
||||
}
|
||||
Some(lsp::CompletionTextEdit::InsertAndReplace(_)) => {
|
||||
log::info!("unsupported insert/replace completion");
|
||||
return None;
|
||||
|
|
Loading…
Reference in a new issue