@@ -1175,6 +1175,7 @@ fn search_impl(
1175 regex: &Regex,
1175 regex: &Regex,
1176 movement: Movement,
1176 movement: Movement,
1177 direction: Direction,
1177 direction: Direction,
1179 let text = doc.text().slice(..);
1180 let text = doc.text().slice(..);
1180 let selection = doc.selection(view.id);
1181 let selection = doc.selection(view.id);
@@ -1233,7 +1234,11 @@ fn search_impl(
1235 doc.set_selection(view.id, selection);
1236 doc.set_selection(view.id, selection);
1237+ if view.is_cursor_in_view(doc, 0) {
1238+ view.ensure_cursor_in_view(doc, scrolloff);
1236− align_view(doc, view, Align::Center);
1240+ align_view(doc, view, Align::Center)
@@ -1257,6 +1262,8 @@ fn rsearch(cx: &mut Context) {
1257// TODO: use one function for search vs extend
1262// TODO: use one function for search vs extend
1258fn searcher(cx: &mut Context, direction: Direction) {
1263fn searcher(cx: &mut Context, direction: Direction) {
1259 let reg = cx.register.unwrap_or('/');
1264 let reg = cx.register.unwrap_or('/');
1265+ let scrolloff = cx.editor.config.scrolloff;
1260 let (_, doc) = current!(cx.editor);
1267 let (_, doc) = current!(cx.editor);
1262 // TODO: could probably share with select_on_matches?
1269 // TODO: could probably share with select_on_matches?
@@ -1281,7 +1288,15 @@ fn searcher(cx: &mut Context, direction: Direction) {
1281 if event != PromptEvent::Update {
1288 if event != PromptEvent::Update {
1284− search_impl(doc, view, &contents, ®ex, Movement::Move, direction);
1291+ search_impl(
@@ -1289,6 +1304,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
1291fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1306fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1307+ let scrolloff = cx.editor.config.scrolloff;
1292 let (view, doc) = current!(cx.editor);
1308 let (view, doc) = current!(cx.editor);
1293 let registers = &cx.editor.registers;
1309 let registers = &cx.editor.registers;
1294 if let Some(query) = registers.read('/') {
1310 if let Some(query) = registers.read('/') {
@@ -1303,7 +1319,7 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
1303 .case_insensitive(case_insensitive)
1319 .case_insensitive(case_insensitive)
1304 .build()
1320 .build()
1306− search_impl(doc, view, &contents, ®ex, movement, direction);
1322+ search_impl(doc, view, &contents, ®ex, movement, direction, scrolloff);
1307 } else {
1323 } else {
1308 // get around warning `mutable_borrow_reservation_conflict`
1324 // get around warning `mutable_borrow_reservation_conflict`
1309 // which will be a hard error in the future
1325 // which will be a hard error in the future