Index: src/global.c =================================================================== --- src/global.c (revision 5162) +++ src/global.c (working copy) @@ -42,6 +42,8 @@ /* Whether the current keystroke is a Meta key. */ bool func_key; /* Whether the current keystroke is an extended keypad value. */ +bool focusing = FALSE; + /* Whether an update of the edit window should center the cursor. */ #ifndef DISABLE_WRAPJUSTIFY ssize_t fill = 0; Index: src/search.c =================================================================== --- src/search.c (revision 5162) +++ src/search.c (working copy) @@ -106,6 +106,7 @@ void search_replace_abort(void) { display_main_list(); + focusing = FALSE; #ifndef NANO_TINY if (openfile->mark_set) edit_refresh(); @@ -118,6 +119,7 @@ /* Initialize the global search and replace strings. */ void search_init_globals(void) { + focusing = TRUE; if (last_search == NULL) last_search = mallocstrcpy(NULL, ""); if (last_replace == NULL) Index: src/proto.h =================================================================== --- src/proto.h (revision 5162) +++ src/proto.h (working copy) @@ -34,6 +34,7 @@ extern bool meta_key; extern bool func_key; +extern bool focusing; #ifndef DISABLE_WRAPJUSTIFY extern ssize_t fill; Index: src/winio.c =================================================================== --- src/winio.c (revision 5162) +++ src/winio.c (working copy) @@ -3161,10 +3161,7 @@ #endif /* !NANO_TINY */ /* Make sure the current line is on the screen. */ - if (ISSET(SMOOTH_SCROLL)) - edit_update(NONE); - else - edit_update(CENTER); + edit_update((ISSET(SMOOTH_SCROLL) && !focusing) ? NONE : CENTER); /* Update old_current if we're not on the same page as * before. */ @@ -3231,7 +3228,7 @@ #endif /* Make sure the current line is on the screen. */ - edit_update(CENTER); + edit_update(ISSET(SMOOTH_SCROLL) ? NONE : CENTER); } foo = openfile->edittop;