From f37f8393302c9f67a0272ba475eccbd784681e65 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 6 Jan 2022 15:32:37 +0100 Subject: [PATCH] Wire up `refresh_anchors` in `Editor::refresh_selections` and call it --- crates/diagnostics/src/diagnostics.rs | 2 ++ crates/editor/src/editor.rs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 8820c1097d9c2c48077974348ace443ada4b9f95..28f82d7fe3c1f4149964b7e2ed1cbff6076a2ae2 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -364,6 +364,8 @@ impl ProjectDiagnosticsEditor { for group_state in &mut groups_to_add { group_state.blocks = block_ids.by_ref().take(group_state.block_count).collect(); } + + editor.refresh_selections(cx); }); for ix in group_ixs_to_remove.into_iter().rev() { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 84735c3aa03f325c1d2df5c9eaa87d5527c630e1..a75e13972482aeaaf97686db236b1911c391fb1c 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3267,8 +3267,17 @@ impl Editor { .flat_map(|selection| [&selection.start, &selection.end]), ) }); - - todo!(); + self.selections = self + .selections + .iter() + .cloned() + .zip(anchors.chunks(2)) + .map(|(mut selection, anchors)| { + selection.start = anchors[0].clone(); + selection.end = anchors[1].clone(); + selection + }) + .collect(); } fn set_selections(&mut self, selections: Arc<[Selection]>, cx: &mut ViewContext) {