diff src/misc1.c @ 9225:b0b2bd8e5217 v7.4.1896

commit https://github.com/vim/vim/commit/82faa259cc42379f2a17d598a2a39d14048685b0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 4 20:14:07 2016 +0200 patch 7.4.1896 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.
author Christian Brabandt <cb@256bit.org>
date Sat, 04 Jun 2016 20:15:06 +0200
parents e600e696c0a1
children f094d4085014
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -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);
 }