From 1b8ea083773fdc95b63603b88bb5870d565484a1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 3 Sep 2021 14:54:24 +0200 Subject: [PATCH] Exclude selections from editor splits in Editor::active_selection_sets --- zed/src/editor.rs | 9 ++++++--- zed/src/editor/element.rs | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zed/src/editor.rs b/zed/src/editor.rs index 71a9174f2e..38e9a3ac3e 100644 --- a/zed/src/editor.rs +++ b/zed/src/editor.rs @@ -1955,10 +1955,13 @@ impl Editor { &'a self, cx: &'a AppContext, ) -> impl 'a + Iterator { - self.buffer - .read(cx) + let buffer = self.buffer.read(cx); + let replica_id = buffer.replica_id(); + buffer .selection_sets() - .filter(|(_, set)| set.active) + .filter(move |(set_id, set)| { + set.active && (set_id.replica_id != replica_id || **set_id == self.selection_set_id) + }) .map(|(set_id, _)| *set_id) } diff --git a/zed/src/editor/element.rs b/zed/src/editor/element.rs index b0a8d97e5d..a14356819d 100644 --- a/zed/src/editor/element.rs +++ b/zed/src/editor/element.rs @@ -450,7 +450,6 @@ impl Element for EditorElement { let mut selections = HashMap::new(); let mut active_rows = BTreeMap::new(); self.update_view(cx.app, |view, cx| { - let replica_id = view.replica_id(cx); for selection_set_id in view.active_selection_sets(cx).collect::>() { let mut set = Vec::new(); for selection in view.selections_in_range( @@ -459,7 +458,7 @@ impl Element for EditorElement { cx, ) { set.push(selection.clone()); - if selection_set_id.replica_id == replica_id { + if selection_set_id == view.selection_set_id { let is_empty = selection.start == selection.end; let mut selection_start; let mut selection_end;