mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 11:01:54 +00:00
Fix accepting partial inline completion (#23312)
Release Notes: - Fixed a bug that could prevent accepting a partial inline completion.
This commit is contained in:
parent
bf0578e32a
commit
5138e6a3c7
1 changed files with 15 additions and 2 deletions
|
@ -4716,8 +4716,19 @@ impl Editor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
InlineCompletion::Edit(edits) => {
|
InlineCompletion::Edit(edits) => {
|
||||||
if edits.len() == 1 && edits[0].0.start == edits[0].0.end {
|
// Find an insertion that starts at the cursor position.
|
||||||
let text = edits[0].1.as_str();
|
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||||
|
let cursor_offset = self.selections.newest::<usize>(cx).head();
|
||||||
|
let insertion = edits.iter().find_map(|(range, text)| {
|
||||||
|
let range = range.to_offset(&snapshot);
|
||||||
|
if range.is_empty() && range.start == cursor_offset {
|
||||||
|
Some(text)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if let Some(text) = insertion {
|
||||||
let mut partial_completion = text
|
let mut partial_completion = text
|
||||||
.chars()
|
.chars()
|
||||||
.by_ref()
|
.by_ref()
|
||||||
|
@ -4740,6 +4751,8 @@ impl Editor {
|
||||||
|
|
||||||
self.refresh_inline_completion(true, true, cx);
|
self.refresh_inline_completion(true, true, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
} else {
|
||||||
|
self.accept_inline_completion(&Default::default(), cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue