From 5f30775d62951c15cce40293d5b31e53f6bd89c3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Sun, 1 Jan 2017 15:19:14 +0100 Subject: [PATCH] inserting: adjust the desired x position (don't restore the old one) This makes nano's cursor behavior consistent across 1) typing text by hand; 2) pasting in text with ^U; 3) inserting text from a file; and 4) redoing with M-E that same typing or pasting or inserting. This fixes https://savannah.gnu.org/bugs/?49968. --- src/files.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/files.c b/src/files.c index df3a9827..9b14ef99 100644 --- a/src/files.c +++ b/src/files.c @@ -1116,7 +1116,6 @@ void do_insertfile(void) size_t was_current_x = openfile->current_x; ssize_t was_current_y = openfile->current_y; bool current_was_at_top = FALSE; - size_t pww_save = openfile->placewewant; #if !defined(NANO_TINY) || !defined(DISABLE_BROWSER) functionptrtype func = func_from_key(&i); #endif @@ -1278,8 +1277,8 @@ void do_insertfile(void) /* Restore the old edittop. */ openfile->edittop = edittop_save; - /* Restore the old place we want. */ - openfile->placewewant = pww_save; + /* Set the desired x position to the current one. */ + openfile->placewewant = xplustabs(); /* Mark the file as modified if it changed. */ if (openfile->current->lineno != was_current_lineno || -- GitLab