From 7fa7b7e507f1c648ded3e4e1a0253f2750e6f74b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 24 Mar 2022 17:16:21 +0100 Subject: [PATCH] Unfold range when selecting the next match Selected matches are unfolded when in project search, buffer search and when hitting `cmd-d` to select the next match. --- crates/editor/src/editor.rs | 2 ++ crates/search/src/buffer_search.rs | 8 +++----- crates/search/src/project_search.rs | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 715f76a07f..0aadc3fab9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3907,6 +3907,7 @@ impl Editor { reversed: false, goal: SelectionGoal::None, }); + self.unfold_ranges([next_selected_range], false, cx); self.update_selections(selections, Some(Autoscroll::Newest), cx); } else { select_next_state.done = true; @@ -3934,6 +3935,7 @@ impl Editor { wordwise: true, done: false, }; + self.unfold_ranges([selection.start..selection.end], false, cx); self.update_selections(selections, Some(Autoscroll::Newest), cx); self.select_next_state = Some(select_state); } else { diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 13c73036f4..a1a40c9e39 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -336,11 +336,9 @@ impl SearchBar { direction, &editor.buffer().read(cx).read(cx), ); - editor.select_ranges( - [ranges[new_index].clone()], - Some(Autoscroll::Fit), - cx, - ); + let range_to_select = ranges[new_index].clone(); + editor.unfold_ranges([range_to_select.clone()], false, cx); + editor.select_ranges([range_to_select], Some(Autoscroll::Fit), cx); } }); } diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 212e1c66a7..d78fcb12b7 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -489,6 +489,7 @@ impl ProjectSearchView { ); let range_to_select = model.match_ranges[new_index].clone(); self.results_editor.update(cx, |editor, cx| { + editor.unfold_ranges([range_to_select.clone()], false, cx); editor.select_ranges([range_to_select], Some(Autoscroll::Fit), cx); }); }