From d9e11f4f78544c280164ca95c979c1b42e46cfec Mon Sep 17 00:00:00 2001 From: jbyuki Date: Wed, 9 Jun 2021 11:35:15 +0200 Subject: fix changed byte ranges for indented lines --- src/nvim/change.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/nvim/change.c') diff --git a/src/nvim/change.c b/src/nvim/change.c index 74e27ca880..39b94bbba1 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1690,18 +1690,22 @@ int open_line( if (trunc_line && !(flags & OPENLINE_KEEPTRAIL)) { truncate_spaces(saved_line); } + ml_replace(curwin->w_cursor.lnum, saved_line, false); int new_len = (int)STRLEN(saved_line); // TODO(vigoux): maybe there is issues there with expandtabs ? + int cols_spliced = 0; if (new_len < curwin->w_cursor.col) { extmark_splice_cols( - curbuf, (int)curwin->w_cursor.lnum, + curbuf, (int)curwin->w_cursor.lnum - 1, new_len, curwin->w_cursor.col - new_len, 0, kExtmarkUndo); + cols_spliced = curwin->w_cursor.col - new_len; } saved_line = NULL; + if (did_append) { changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col, curwin->w_cursor.lnum + 1, 1L, true); @@ -1715,13 +1719,14 @@ int open_line( } // Always move extmarks - Here we move only the line where the // cursor is, the previous mark_adjust takes care of the lines after - int cols_added = mincol-1+less_cols_off-less_cols; - extmark_splice(curbuf, (int)lnum-1, mincol-1, + int cols_added = mincol-1+less_cols_off-less_cols-new_len; + extmark_splice(curbuf, (int)lnum-1, mincol-1 - cols_spliced, 0, less_cols_off, less_cols_off, 1, cols_added, 1 + cols_added, kExtmarkUndo); } else { changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col); } + } // Put the cursor on the new line. Careful: the scrollup() above may -- cgit From a1db340cea485c6c616bd64afb53a9e6430944fc Mon Sep 17 00:00:00 2001 From: jbyuki Date: Wed, 9 Jun 2021 11:57:37 +0200 Subject: minor fixes --- src/nvim/change.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/change.c') diff --git a/src/nvim/change.c b/src/nvim/change.c index 39b94bbba1..b673683460 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1690,7 +1690,6 @@ int open_line( if (trunc_line && !(flags & OPENLINE_KEEPTRAIL)) { truncate_spaces(saved_line); } - ml_replace(curwin->w_cursor.lnum, saved_line, false); int new_len = (int)STRLEN(saved_line); @@ -1705,7 +1704,6 @@ int open_line( } saved_line = NULL; - if (did_append) { changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col, curwin->w_cursor.lnum + 1, 1L, true); @@ -1726,7 +1724,6 @@ int open_line( } else { changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col); } - } // Put the cursor on the new line. Careful: the scrollup() above may -- cgit From 7ff7ca56ddda5db11cd84017b47c3b2962243a39 Mon Sep 17 00:00:00 2001 From: jbyuki Date: Wed, 9 Jun 2021 11:58:25 +0200 Subject: minor fix --- src/nvim/change.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/change.c') diff --git a/src/nvim/change.c b/src/nvim/change.c index b673683460..c0183d4317 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1717,7 +1717,7 @@ int open_line( } // Always move extmarks - Here we move only the line where the // cursor is, the previous mark_adjust takes care of the lines after - int cols_added = mincol-1+less_cols_off-less_cols-new_len; + int cols_added = mincol-1+less_cols_off-less_cols; extmark_splice(curbuf, (int)lnum-1, mincol-1 - cols_spliced, 0, less_cols_off, less_cols_off, 1, cols_added, 1 + cols_added, kExtmarkUndo); -- cgit