Mercurial > vim
comparison src/change.c @ 31762:b53ab3c3e0c9 v9.0.1213
patch 9.0.1213: adding a line below the last one does not expand fold
Commit: https://github.com/vim/vim/commit/da3dd7d857ba4fb4bf408dedd1d9d6a2d5e2ae9f
Author: Brandon Simmons <simmsbra@gmail.com>
Date: Tue Jan 17 19:48:07 2023 +0000
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 17 Jan 2023 21:00:05 +0100 |
parents | b6bef244837e |
children | 984969b81d63 |
comparison
equal
deleted
inserted
replaced
31761:a89d17654b30 | 31762:b53ab3c3e0c9 |
---|---|
770 * Like appended_lines(), but adjust marks first. | 770 * Like appended_lines(), but adjust marks first. |
771 */ | 771 */ |
772 void | 772 void |
773 appended_lines_mark(linenr_T lnum, long count) | 773 appended_lines_mark(linenr_T lnum, long count) |
774 { | 774 { |
775 // Skip mark_adjust when adding a line after the last one, there can't | 775 mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L); |
776 // be marks there. But it's still needed in diff mode. | |
777 if (lnum + count < curbuf->b_ml.ml_line_count | |
778 #ifdef FEAT_DIFF | |
779 || curwin->w_p_diff | |
780 #endif | |
781 ) | |
782 mark_adjust(lnum + 1, (linenr_T)MAXLNUM, count, 0L); | |
783 changed_lines(lnum + 1, 0, lnum + 1, count); | 776 changed_lines(lnum + 1, 0, lnum + 1, count); |
784 } | 777 } |
785 | 778 |
786 /* | 779 /* |
787 * Deleted "count" lines at line "lnum" in the current buffer. | 780 * Deleted "count" lines at line "lnum" in the current buffer. |
2140 if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE) | 2133 if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE) |
2141 == FAIL) | 2134 == FAIL) |
2142 goto theend; | 2135 goto theend; |
2143 // Postpone calling changed_lines(), because it would mess up folding | 2136 // Postpone calling changed_lines(), because it would mess up folding |
2144 // with markers. | 2137 // with markers. |
2145 // Skip mark_adjust when adding a line after the last one, there can't | 2138 mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); |
2146 // be marks there. But still needed in diff mode. | |
2147 if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count | |
2148 #ifdef FEAT_DIFF | |
2149 || curwin->w_p_diff | |
2150 #endif | |
2151 ) | |
2152 mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L); | |
2153 did_append = TRUE; | 2139 did_append = TRUE; |
2154 #ifdef FEAT_PROP_POPUP | 2140 #ifdef FEAT_PROP_POPUP |
2155 if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) | 2141 if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) |
2156 // Properties after the split move to the next line. | 2142 // Properties after the split move to the next line. |
2157 adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum, | 2143 adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum, |