To: vim_dev@googlegroups.com Subject: Patch 9.0.1213 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1213 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) Files: src/change.c, src/register.c, src/testdir/test_fold.vim *** ../vim-9.0.1212/src/change.c 2022-12-02 15:58:34.602705473 +0000 --- src/change.c 2023-01-17 19:42:11.803721605 +0000 *************** *** 772,785 **** 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); changed_lines(lnum + 1, 0, lnum + 1, count); } --- 772,778 ---- void appended_lines_mark(linenr_T lnum, long count) { ! mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L); changed_lines(lnum + 1, 0, lnum + 1, count); } *************** *** 2142,2155 **** 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); did_append = TRUE; #ifdef FEAT_PROP_POPUP if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) --- 2135,2141 ---- 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); did_append = TRUE; #ifdef FEAT_PROP_POPUP if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) *** ../vim-9.0.1212/src/register.c 2022-11-02 13:30:37.538314551 +0000 --- src/register.c 2023-01-17 19:42:11.803721605 +0000 *************** *** 2208,2222 **** 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), (linenr_T)MAXLNUM, nr_lines, 0L); // note changed text for displaying and folding --- 2208,2214 ---- if (dir == FORWARD) curbuf->b_op_start.lnum++; } ! mark_adjust(curbuf->b_op_start.lnum + (y_type == MCHAR), (linenr_T)MAXLNUM, nr_lines, 0L); // note changed text for displaying and folding *** ../vim-9.0.1212/src/testdir/test_fold.vim 2023-01-13 14:17:54.014430905 +0000 --- src/testdir/test_fold.vim 2023-01-17 19:47:20.847403068 +0000 *************** *** 1683,1686 **** --- 1683,1699 ---- bwipe! endfunc + " Make sure that when there is a fold at the bottom of the buffer and a newline + " character is appended to the line, the fold gets expanded (instead of the new + " line not being part of the fold). + func Test_expand_fold_at_bottom_of_buffer() + new + " create a fold on the only line + fold + execute "normal A\" + call assert_equal([1, 1], range(1, 2)->map('foldlevel(v:val)')) + + bwipe! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1212/src/version.c 2023-01-17 18:31:20.427373305 +0000 --- src/version.c 2023-01-17 19:44:20.627754356 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1213, /**/ -- How To Keep A Healthy Level Of Insanity: 5. Put decaf in the coffee maker for 3 weeks. Once everyone has gotten over their caffeine addictions, switch to espresso. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///