Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix panic when calculating inline completion (#22180)

Thorsten Ball246912278459
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 8ffac575035..8673e1f6d32 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -4737,16 +4737,10 @@ impl Editor {
let edits = completion
.edits
.into_iter()
- .map(|(range, new_text)| {
- (
- multibuffer
- .anchor_in_excerpt(excerpt_id, range.start)
- .unwrap()
- ..multibuffer
- .anchor_in_excerpt(excerpt_id, range.end)
- .unwrap(),
- new_text,
- )
+ .flat_map(|(range, new_text)| {
+ let start = multibuffer.anchor_in_excerpt(excerpt_id, range.start)?;
+ let end = multibuffer.anchor_in_excerpt(excerpt_id, range.end)?;
+ Some((start..end, new_text))
})
.collect::<Vec<_>>();
if edits.is_empty() {