From e8416bb64446a48a58f7e61d867c46dede0809f8 Mon Sep 17 00:00:00 2001 From: Anatol Ulrich <45840+spookyvision@users.noreply.github.com> Date: Wed, 3 Nov 2021 15:44:46 +0100 Subject: [PATCH] Update crates/text_edit/src/lib.rs Co-authored-by: Lukas Wirth --- crates/text_edit/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/text_edit/src/lib.rs b/crates/text_edit/src/lib.rs index bc16778d34e..21c622d3d6b 100644 --- a/crates/text_edit/src/lib.rs +++ b/crates/text_edit/src/lib.rs @@ -123,7 +123,8 @@ pub fn union(&mut self, other: TextEdit) -> Result<(), TextEdit> { self.indels.extend(other.indels); check_disjoint_and_sort(&mut self.indels); - self.indels.dedup(); + // Only dedup deletions and replacements, keep all insertions + self.indels.dedup_by(|a, b| a == b && !a.delete.is_empty()); Ok(()) }