Skip to content

Commit c927d61

Browse files
authored
Fix bugs in search wraparound message (#4101)
1 parent ccb38e7 commit c927d61

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

helix-term/src/commands.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ fn split_selection_on_newline(cx: &mut Context) {
15611561
doc.set_selection(view.id, selection);
15621562
}
15631563

1564+
#[allow(clippy::too_many_arguments)]
15641565
fn search_impl(
15651566
editor: &mut Editor,
15661567
contents: &str,
@@ -1569,6 +1570,7 @@ fn search_impl(
15691570
direction: Direction,
15701571
scrolloff: usize,
15711572
wrap_around: bool,
1573+
show_warnings: bool,
15721574
) {
15731575
let (view, doc) = current!(editor);
15741576
let text = doc.text().slice(..);
@@ -1609,9 +1611,13 @@ fn search_impl(
16091611
regex.find_iter(&contents[start..]).last()
16101612
}
16111613
};
1612-
editor.set_status("Wrapped around document");
1613-
} else {
1614-
editor.set_error("No more matches");
1614+
}
1615+
if show_warnings {
1616+
if wrap_around && mat.is_some() {
1617+
editor.set_status("Wrapped around document");
1618+
} else {
1619+
editor.set_error("No more matches");
1620+
}
16151621
}
16161622
}
16171623

@@ -1706,6 +1712,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
17061712
direction,
17071713
scrolloff,
17081714
wrap_around,
1715+
false,
17091716
);
17101717
},
17111718
);
@@ -1740,6 +1747,7 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
17401747
direction,
17411748
scrolloff,
17421749
wrap_around,
1750+
true,
17431751
);
17441752
}
17451753
} else {

0 commit comments

Comments
 (0)