From f42aa95fbc7b949213ed204dfd0310e182e7e378 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 18 Jan 2020 13:19:36 +0100 Subject: extmark: separate extmark_splice_cols for column-only change as the byte logic will be the same for all of these --- 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 51afb40b40..df95b583cd 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -366,7 +366,7 @@ void changed_bytes(linenr_T lnum, colnr_T col) static void inserted_bytes(linenr_T lnum, colnr_T col, int old, int new) { if (curbuf_splice_pending == 0) { - extmark_splice(curbuf, (int)lnum-1, col, 0, old, 0, new, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum-1, col, old, new, kExtmarkUndo); } changed_bytes(lnum, col); -- cgit From bc86f76c0a1d3234b749a105c9aae65f84c51320 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 29 Feb 2020 15:27:17 +0100 Subject: api/buffer: add "on_bytes" callback to nvim_buf_attach This implements byte-resolution updates of buffer changes. Note: there is no promise that the buffer state is valid inside the callback! --- src/nvim/change.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/nvim/change.c') diff --git a/src/nvim/change.c b/src/nvim/change.c index df95b583cd..6ffc26332a 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1597,7 +1597,7 @@ int open_line( if (curwin->w_cursor.lnum + 1 < curbuf->b_ml.ml_line_count || curwin->w_p_diff) { mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1L, 0L, - kExtmarkUndo); + kExtmarkNOOP); } did_append = true; } else { @@ -1611,6 +1611,7 @@ int open_line( } ml_replace(curwin->w_cursor.lnum, p_extra, true); changed_bytes(curwin->w_cursor.lnum, 0); + // TODO: extmark_splice_cols here?? curwin->w_cursor.lnum--; did_append = false; } @@ -1691,8 +1692,9 @@ 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, 0, less_cols_off, - 1, cols_added, kExtmarkUndo); + extmark_splice(curbuf, (int)lnum-1, mincol-1, + 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); } @@ -1704,8 +1706,10 @@ int open_line( } if (did_append) { changed_lines(curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L, true); - extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, - 0, 0, 0, 1, 0, kExtmarkUndo); + // bail out and just get the final lenght of the line we just manipulated + bcount_t extra = (bcount_t)STRLEN(ml_get(curwin->w_cursor.lnum)); + extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, 0, + 0, 0, 0, 1, 0, 1+extra, kExtmarkUndo); } curbuf_splice_pending--; -- cgit From 82fb6a881805658359777ab172f91d1a84b91b8d Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Mon, 29 Jun 2020 18:34:45 +0200 Subject: fix lints --- 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 6ffc26332a..5e1ec616f6 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1611,7 +1611,7 @@ int open_line( } ml_replace(curwin->w_cursor.lnum, p_extra, true); changed_bytes(curwin->w_cursor.lnum, 0); - // TODO: extmark_splice_cols here?? + // TODO(vigoux): extmark_splice_cols here?? curwin->w_cursor.lnum--; did_append = false; } -- cgit