Skip to content

Commit 4bebcd6

Browse files
A-Walruspathwave
authored andcommitted
Fix bugs in search wraparound message (helix-editor#4101)
1 parent d61a1a5 commit 4bebcd6

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
@@ -1564,6 +1564,7 @@ fn split_selection_on_newline(cx: &mut Context) {
15641564
doc.set_selection(view.id, selection);
15651565
}
15661566

1567+
#[allow(clippy::too_many_arguments)]
15671568
fn search_impl(
15681569
editor: &mut Editor,
15691570
contents: &str,
@@ -1572,6 +1573,7 @@ fn search_impl(
15721573
direction: Direction,
15731574
scrolloff: usize,
15741575
wrap_around: bool,
1576+
show_warnings: bool,
15751577
) {
15761578
let (view, doc) = current!(editor);
15771579
let text = doc.text().slice(..);
@@ -1612,9 +1614,13 @@ fn search_impl(
16121614
regex.find_iter(&contents[start..]).last()
16131615
}
16141616
};
1615-
editor.set_status("Wrapped around document");
1616-
} else {
1617-
editor.set_error("No more matches");
1617+
}
1618+
if show_warnings {
1619+
if wrap_around && mat.is_some() {
1620+
editor.set_status("Wrapped around document");
1621+
} else {
1622+
editor.set_error("No more matches");
1623+
}
16181624
}
16191625
}
16201626

@@ -1713,6 +1719,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
17131719
direction,
17141720
scrolloff,
17151721
wrap_around,
1722+
false,
17161723
);
17171724
},
17181725
);
@@ -1747,6 +1754,7 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
17471754
direction,
17481755
scrolloff,
17491756
wrap_around,
1757+
true,
17501758
);
17511759
}
17521760
} else {

0 commit comments

Comments
 (0)