]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1896 v7.4.1896
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Jun 2016 18:14:07 +0000 (20:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Jun 2016 18:14:07 +0000 (20:14 +0200)
Problem:    Invoking mark_adjust() when adding a new line below the last line
            is pointless.
Solution:   Skip calling mark_adjust() when appending below the last line.

src/misc1.c
src/ops.c
src/version.c

index 9fa85781aa0076f2a9fd5e30426d2c3607107ee5..79699689387d7e4d0ee0ceb5e83419350d2e2a47 100644 (file)
@@ -1425,8 +1425,11 @@ open_line(
                                                                      == FAIL)
            goto theend;
        /* Postpone calling changed_lines(), because it would mess up folding
-        * with markers. */
-       mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
+        * with markers.
+        * Skip mark_adjust when adding a line after the last one, there can't
+        * be marks there. */
+       if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count)
+           mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
        did_append = TRUE;
     }
 #ifdef FEAT_VREPLACE
@@ -2861,7 +2864,10 @@ appended_lines(linenr_T lnum, long count)
     void
 appended_lines_mark(linenr_T lnum, long count)
 {
-    mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L);
+    /* Skip mark_adjust when adding a line after the last one, there can't
+     * be marks there. */
+    if (lnum + count < curbuf->b_ml.ml_line_count)
+       mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L);
     changed_lines(lnum + 1, 0, lnum + 1, count);
 }
 
index 983d9d0e6b2338b02a13ef8e3215668e5c3745b7..35f2d2e95fdf1f8e171f06864abc28c167a97654 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -3885,7 +3885,11 @@ error:
                if (dir == FORWARD)
                    curbuf->b_op_start.lnum++;
            }
-           mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
+           /* Skip mark_adjust when adding lines after the last one, there
+            * can't be marks there. */
+           if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines
+                                                < curbuf->b_ml.ml_line_count)
+               mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
                                             (linenr_T)MAXLNUM, nr_lines, 0L);
 
            /* note changed text for displaying and folding */
index 1e7c2f290d6a1229c74b7ee3bfe073d5288a900d..c6ebdc45b9075512db1c359f6829725958fdc7d9 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1896,
 /**/
     1895,
 /**/