Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix word completions clobbering the text after the cursor (#32010)
Michael Sloan5ae8c4cf09b7
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 796cbdac378..913aad22a5e 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -5106,14 +5106,15 @@ impl Editor {trigger_kind,};- let (replace_range, word_kind) = buffer_snapshot.surrounding_word(buffer_position);- let (replace_range, word_to_exclude) = if word_kind == Some(CharKind::Word) {+ let (word_replace_range, word_to_exclude) = if let (word_range, Some(CharKind::Word)) =+ buffer_snapshot.surrounding_word(buffer_position)+ {let word_to_exclude = buffer_snapshot- .text_for_range(replace_range.clone())+ .text_for_range(word_range.clone()).collect::<String>();(- buffer_snapshot.anchor_before(replace_range.start)- ..buffer_snapshot.anchor_after(replace_range.end),+ buffer_snapshot.anchor_before(word_range.start)+ ..buffer_snapshot.anchor_after(buffer_position),Some(word_to_exclude),)} else {@@ -5221,7 +5222,7 @@ impl Editor {words.remove(&lsp_completion.new_text);}completions.extend(words.into_iter().map(|(word, word_range)| Completion {- replace_range: replace_range.clone(),+ replace_range: word_replace_range.clone(),new_text: word.clone(),label: CodeLabel::plain(word, None),icon_path: None,