mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Don't highlight project search matches either (#2807)
@JosephTLyons this is probably worth merging alongside #2803 - vim: Fix a bug where focusing project search results unexpectedly entered visual mode
This commit is contained in:
commit
5d8370e2a1
2 changed files with 7 additions and 2 deletions
|
@ -1537,7 +1537,7 @@ impl Editor {
|
||||||
self.collapse_matches = collapse_matches;
|
self.collapse_matches = collapse_matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn range_for_match<T: std::marker::Copy>(&self, range: &Range<T>) -> Range<T> {
|
pub fn range_for_match<T: std::marker::Copy>(&self, range: &Range<T>) -> Range<T> {
|
||||||
if self.collapse_matches {
|
if self.collapse_matches {
|
||||||
return range.start..range.start;
|
return range.start..range.start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,6 +743,7 @@ impl ProjectSearchView {
|
||||||
|
|
||||||
let range_to_select = match_ranges[new_index].clone();
|
let range_to_select = match_ranges[new_index].clone();
|
||||||
self.results_editor.update(cx, |editor, cx| {
|
self.results_editor.update(cx, |editor, cx| {
|
||||||
|
let range_to_select = editor.range_for_match(&range_to_select);
|
||||||
editor.unfold_ranges([range_to_select.clone()], false, true, cx);
|
editor.unfold_ranges([range_to_select.clone()], false, true, cx);
|
||||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||||
s.select_ranges([range_to_select])
|
s.select_ranges([range_to_select])
|
||||||
|
@ -784,8 +785,12 @@ impl ProjectSearchView {
|
||||||
let is_new_search = self.search_id != prev_search_id;
|
let is_new_search = self.search_id != prev_search_id;
|
||||||
self.results_editor.update(cx, |editor, cx| {
|
self.results_editor.update(cx, |editor, cx| {
|
||||||
if is_new_search {
|
if is_new_search {
|
||||||
|
let range_to_select = match_ranges
|
||||||
|
.first()
|
||||||
|
.clone()
|
||||||
|
.map(|range| editor.range_for_match(range));
|
||||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||||
s.select_ranges(match_ranges.first().cloned())
|
s.select_ranges(range_to_select)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
editor.highlight_background::<Self>(
|
editor.highlight_background::<Self>(
|
||||||
|
|
Loading…
Reference in a new issue