From fb35f155263ef82d9b4d6ee5ed8d73a8a99beb8f Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 22 Aug 2024 17:16:07 -0600 Subject: [PATCH] Fix linked ranges + multi-cursor (#16707) Closes: #16695 Release Notes: - Fixed double edits when a multi-cursor is in a linked editing range --- crates/editor/src/editor.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1414d3c65b21ea190242202b833b8cafceb6f05b..e1a72fc3849717ab97d035cf774c197b56f6731c 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3016,6 +3016,17 @@ impl Editor { if start_offset > buffer_snapshot.len() || end_offset > buffer_snapshot.len() { continue; } + if self.selections.disjoint_anchor_ranges().iter().any(|s| { + if s.start.buffer_id != selection.start.buffer_id + || s.end.buffer_id != selection.end.buffer_id + { + return false; + } + TO::to_offset(&s.start.text_anchor, &buffer_snapshot) <= end_offset + && TO::to_offset(&s.end.text_anchor, &buffer_snapshot) >= start_offset + }) { + continue; + } let start = buffer_snapshot.anchor_after(start_offset); let end = buffer_snapshot.anchor_after(end_offset); linked_edits