]> git.wh0rd.org Git - nano.git/commitdiff
more fixes for uncutting text/inserting files with the mark on
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Thu, 16 Aug 2007 03:23:30 +0000 (03:23 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Thu, 16 Aug 2007 03:23:30 +0000 (03:23 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4156 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c
src/nano.c

index a6ecddd28bdf6a2822b1b5d7bb0b82c67acf1801..f9ce33fa92f907414969086003f042c89807f6ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,7 +28,7 @@ CVS code -
 - files.c:
   do_insertfile()
        - Make sure the mark is always properly positioned after
-         inserting a one-line file with the mark on. (DLR)
+         inserting a file with the mark on. (DLR)
   copy_file()
        - Assert that inn and out don't both point to the same file.
          (DLR)
@@ -42,7 +42,7 @@ CVS code -
          the mark on by properly preserving the beginning of the mark.
          (DLR, found by Paul Goins)
        - Make sure the mark is always properly positioned after
-         uncutting one line of text with the mark on. (DLR)
+         uncutting text with the mark on. (DLR)
 - prompt.c:
   do_yesno_prompt()
        - Remove redundant check for NO_HELP's being FALSE. (DLR)
index a4246e0f6eb19be044f7c25b66c51ab2f76c4735..87ee50cb30028d47c1d06f8bebe76f0c56f2bbe6 100644 (file)
@@ -814,7 +814,10 @@ void do_insertfile(
 #ifndef NANO_TINY
                if (openfile->mark_set)
                    do_mark_shift = (openfile->current_x <=
-                       openfile->mark_begin_x);
+                       openfile->mark_begin_x ||
+                       openfile->current->lineno <=
+                       openfile->mark_begin->lineno);
+
 #endif
 #ifdef ENABLE_MULTIBUFFER
            }
@@ -890,8 +893,12 @@ void do_insertfile(
                                openfile->current_x;
                    }
 #endif
-                   openfile->current_x += strlen(filepart->top_data);
+                   openfile->current_x += current_x_save;
                }
+#ifndef NANO_TINY
+               else if (openfile->mark_set && do_mark_shift)
+                   openfile->mark_begin_x -= current_x_save;
+#endif
 
                /* Update the current y-coordinate to account for the
                 * number of lines inserted. */
index ddd94f6d453ffa7323531f63210b79983347483b..f5a047f755a830d7291f90806b89901383132bc3 100644 (file)
@@ -392,6 +392,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
 void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
 {
     filestruct *top_save;
+    size_t current_x_save = openfile->current_x;
     bool edittop_inside;
 #ifndef NANO_TINY
     bool do_mark_shift = FALSE;
@@ -408,7 +409,9 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
     edittop_inside = (openfile->edittop == openfile->fileage);
 #ifndef NANO_TINY
     if (openfile->mark_set)
-       do_mark_shift = (openfile->current_x <= openfile->mark_begin_x);
+       do_mark_shift = (openfile->current_x <=
+               openfile->mark_begin_x || openfile->current->lineno <=
+               openfile->mark_begin->lineno);
 #endif
 
     /* Put the top and bottom of the filestruct at copies of file_top
@@ -431,8 +434,12 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
                openfile->mark_begin_x += openfile->current_x;
        }
 #endif
-       openfile->current_x += strlen(filepart->top_data);
+       openfile->current_x += current_x_save;
     }
+#ifndef NANO_TINY
+    else if (openfile->mark_set && do_mark_shift)
+       openfile->mark_begin_x -= current_x_save;
+#endif
 
     /* Get the number of characters in the copied text, and add it to
      * totsize. */