]> git.wh0rd.org Git - nano.git/commitdiff
fix cursor placement problem when inserting into the current buffer at
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Mon, 15 Nov 2004 21:49:21 +0000 (21:49 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Mon, 15 Nov 2004 21:49:21 +0000 (21:49 +0000)
the bottom of the edit window with smooth scrolling on

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2098 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

src/files.c

index 592aaa3a52f11ba4d11830db4a1fea0fd1c767cc..0c800228bcd940237d04f412785703c649e47b04 100644 (file)
@@ -499,6 +499,7 @@ void do_insertfile(
     char *ans = mallocstrcpy(NULL, "");
        /* The last answer the user typed on the statusbar. */
     filestruct *edittop_save = edittop;
+    int current_y_save = current_y;
     bool at_edittop = FALSE;
        /* Whether we're at the top of the edit window. */
 
@@ -620,6 +621,15 @@ void do_insertfile(
            {
                filestruct *top_save = fileage;
 
+               /* If we didn't insert into a new buffer, and we were at
+                * the top of the edit window before, set the saved
+                * value of edittop to the new top of the edit window,
+                * and update the current y-coordinate to account for
+                * the number of lines inserted. */
+               if (at_edittop)
+                   edittop_save = fileage;
+               current_y += current_y_save;
+
                /* If we didn't insert into a new buffer, unpartition
                 * the filestruct so that it contains all the text
                 * again.  Note that we've replaced the non-text
@@ -631,12 +641,6 @@ void do_insertfile(
                 * partition. */
                renumber(top_save);
 
-               /* If we were at the top of the edit window before, set
-                * the saved value of edittop to the new top of the edit
-                * window. */
-               if (at_edittop)
-                   edittop_save = fileage;
-
                /* Set edittop back to what it was before. */
                edittop = edittop_save;
            }