diff options
author | Jurica Bradarić <jbradaric@users.noreply.github.com> | 2016-08-29 20:35:48 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-08-29 14:35:48 -0400 |
commit | 7fd771619f2a2e2fe6007aaa6aa9a02cbdd205bd (patch) | |
tree | 281a5df1b0fee3cf2c5866184b8216d5b21cbc02 | |
parent | 10a54ad12e2d78c629220c4266066cf9b997d684 (diff) | |
download | rneovim-7fd771619f2a2e2fe6007aaa6aa9a02cbdd205bd.tar.gz rneovim-7fd771619f2a2e2fe6007aaa6aa9a02cbdd205bd.tar.bz2 rneovim-7fd771619f2a2e2fe6007aaa6aa9a02cbdd205bd.zip |
vim-patch:7.4.1896 (#5258)
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.
https://github.com/vim/vim/commit/82faa259cc42379f2a17d598a2a39d14048685b0
-rw-r--r-- | src/nvim/misc1.c | 18 | ||||
-rw-r--r-- | src/nvim/ops.c | 9 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index d72d8e8513..cab4edfec8 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -742,10 +742,14 @@ open_line ( if (ml_append(curwin->w_cursor.lnum, p_extra, (colnr_T)0, FALSE) == 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); - did_append = TRUE; + // 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. + 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; } else { /* * In VREPLACE mode we are starting to replace the next line. @@ -1871,7 +1875,11 @@ void 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); } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 990b95829a..0aae7f5c46 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3110,8 +3110,13 @@ error: if (dir == FORWARD) curbuf->b_op_start.lnum++; } - mark_adjust(curbuf->b_op_start.lnum + (y_type == kMTCharWise), - (linenr_T)MAXLNUM, nr_lines, 0L); + // Skip mark_adjust when adding lines after the last one, there + // can't be marks there. + if (curbuf->b_op_start.lnum + (y_type == kMTCharWise) - 1 + nr_lines + < curbuf->b_ml.ml_line_count) { + mark_adjust(curbuf->b_op_start.lnum + (y_type == kMTCharWise), + (linenr_T)MAXLNUM, nr_lines, 0L); + } // note changed text for displaying and folding if (y_type == kMTCharWise) { diff --git a/src/nvim/version.c b/src/nvim/version.c index 6060654bb5..464039241e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -380,7 +380,7 @@ static int included_patches[] = { // 1899 NA 1898, // 1897, - // 1896, + 1896, // 1895, // 1894 NA // 1893, |