== 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
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);
}
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 */