diff --git a/src/files.c b/src/files.c index b1c5f5add1eed0451877327a23c8e793ae6aef9b..e30c47fbbf480627d6df0441ba02315ca1db4e36 100644 --- a/src/files.c +++ b/src/files.c @@ -1111,7 +1111,6 @@ void do_insertfile(void) filestruct *edittop_save = openfile->edittop; ssize_t was_current_lineno = openfile->current->lineno; size_t was_current_x = openfile->current_x; - ssize_t was_current_y = openfile->current_y; bool current_was_at_top = FALSE; #if !defined(NANO_TINY) || !defined(DISABLE_BROWSER) functionptrtype func = func_from_key(&i); @@ -1257,9 +1256,6 @@ void do_insertfile(void) } } #endif - /* Update the current y-coordinate to account for the - * number of lines inserted. */ - openfile->current_y += was_current_y; /* Unpartition the filestruct so that it contains all * the text again. Note that we've replaced the @@ -1282,6 +1278,10 @@ void do_insertfile(void) openfile->current_x != was_current_x) set_modified(); + /* Update the cursor position to account for the number + * of lines inserted. */ + reset_cursor(); + refresh_needed = TRUE; }