patch 9.0.1213: adding a line below the last one does not expand fold
Problem: Adding a line below the last one does not expand fold.
Solution: Do not skip mark_adjust() when adding lines below the last one.
(Brandon Simmons, closes #11832, closes #10698)
diff --git a/src/change.c b/src/change.c
index dc68d3c..1e7bdd6 100644
--- a/src/change.c
+++ b/src/change.c
@@ -772,14 +772,7 @@
void
appended_lines_mark(linenr_T lnum, long count)
{
- // Skip mark_adjust when adding a line after the last one, there can't
- // be marks there. But it's still needed in diff mode.
- if (lnum + count < curbuf->b_ml.ml_line_count
-#ifdef FEAT_DIFF
- || curwin->w_p_diff
-#endif
- )
- mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L);
+ mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L);
changed_lines(lnum + 1, 0, lnum + 1, count);
}
@@ -2142,14 +2135,7 @@
goto theend;
// Postpone calling changed_lines(), because it would mess up folding
// with markers.
- // Skip mark_adjust when adding a line after the last one, there can't
- // be marks there. But still needed in diff mode.
- if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count
-#ifdef FEAT_DIFF
- || curwin->w_p_diff
-#endif
- )
- mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
+ mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L);
did_append = TRUE;
#ifdef FEAT_PROP_POPUP
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
diff --git a/src/register.c b/src/register.c
index bc687c0..3454cfa 100644
--- a/src/register.c
+++ b/src/register.c
@@ -2208,15 +2208,7 @@
if (dir == FORWARD)
curbuf->b_op_start.lnum++;
}
- // Skip mark_adjust when adding lines after the last one, there
- // can't be marks there. But still needed in diff mode.
- if (curbuf->b_op_start.lnum + (y_type == MCHAR) - 1 + nr_lines
- < curbuf->b_ml.ml_line_count
-#ifdef FEAT_DIFF
- || curwin->w_p_diff
-#endif
- )
- mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
+ mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR),
(linenr_T)MAXLNUM, nr_lines, 0L);
// note changed text for displaying and folding
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index f915a66..7f75e91 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
Binary files differ
diff --git a/src/version.c b/src/version.c
index 3496b3a..ae5de35 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1213,
+/**/
1212,
/**/
1211,