diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-01-18 13:19:36 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-09-09 21:22:21 +0200 |
commit | f42aa95fbc7b949213ed204dfd0310e182e7e378 (patch) | |
tree | 77fda6bec3601339c0c7b7ef2447950836befe3d | |
parent | a621c45ba07e3608aad714403178e3aaded15df7 (diff) | |
download | rneovim-f42aa95fbc7b949213ed204dfd0310e182e7e378.tar.gz rneovim-f42aa95fbc7b949213ed204dfd0310e182e7e378.tar.bz2 rneovim-f42aa95fbc7b949213ed204dfd0310e182e7e378.zip |
extmark: separate extmark_splice_cols for column-only change
as the byte logic will be the same for all of these
-rw-r--r-- | src/nvim/change.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 8 | ||||
-rw-r--r-- | src/nvim/extmark.c | 7 | ||||
-rw-r--r-- | src/nvim/fold.c | 3 | ||||
-rw-r--r-- | src/nvim/ops.c | 36 |
5 files changed, 24 insertions, 32 deletions
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); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ea38221dc7..1e149da1dc 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1919,10 +1919,10 @@ change_indent ( // TODO(bfredl): test for crazy edge cases, like we stand on a TAB or // something? does this even do the right text change then? int delta = orig_col - new_col; - extmark_splice(curbuf, curwin->w_cursor.lnum-1, new_col, - 0, delta < 0 ? -delta : 0, - 0, delta > 0 ? delta : 0, - kExtmarkUndo); + extmark_splice_cols(curbuf, curwin->w_cursor.lnum-1, new_col, + delta < 0 ? -delta : 0, + delta > 0 ? delta : 0, + kExtmarkUndo); } } diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index c9b1c72828..91ca525533 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -552,6 +552,7 @@ void extmark_adjust(buf_T *buf, } } + void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int oldextent_row, colnr_T oldextent_col, @@ -631,12 +632,10 @@ void extmark_splice(buf_T *buf, void extmark_splice_cols(buf_T *buf, int start_row, colnr_T start_col, - colnr_T old_col, colnr_T new_col, + colnr_T oldextent, colnr_T newextent, ExtmarkOp undo) { - extmark_splice(buf, start_row, start_col, - 0, old_col, - 0, new_col, undo); + extmark_splice(buf, start_row, start_col, 0, oldextent, 0, newextent, undo); } void extmark_move_region(buf_T *buf, diff --git a/src/nvim/fold.c b/src/nvim/fold.c index c29b878491..9994ad3ea8 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1744,8 +1744,7 @@ static void foldDelMarker( STRCPY(newline + (p - line), p + len); ml_replace_buf(buf, lnum, newline, false); extmark_splice_cols(buf, (int)lnum-1, (int)(p - line), - (int)len, - 0, kExtmarkUndo); + (int)len, 0, kExtmarkUndo); } break; } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 7e0cd737ca..14cd189bc3 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -496,9 +496,9 @@ static void shift_block(oparg_T *oap, int amount) // replace the line ml_replace(curwin->w_cursor.lnum, newp, false); changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol); - extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, startcol, - 0, oldlen, 0, newlen, - kExtmarkUndo); + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, startcol, + oldlen, newlen, + kExtmarkUndo); State = oldstate; curwin->w_cursor.col = oldcol; p_ri = old_p_ri; @@ -595,9 +595,8 @@ static void block_insert(oparg_T *oap, char_u *s, int b_insert, struct block_def STRMOVE(newp + offset, oldp); ml_replace(lnum, newp, false); - extmark_splice(curbuf, (int)lnum-1, startcol, - 0, skipped, - 0, offset-startcol, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum-1, startcol, + skipped, offset-startcol, kExtmarkUndo); if (lnum == oap->end.lnum) { /* Set "']" mark to the end of the block instead of the end of @@ -1534,10 +1533,9 @@ int op_delete(oparg_T *oap) // replace the line ml_replace(lnum, newp, false); - extmark_splice(curbuf, (int)lnum-1, bd.textcol, - 0, bd.textlen, - 0, bd.startspaces+bd.endspaces, - kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum-1, bd.textcol, + bd.textlen, bd.startspaces+bd.endspaces, + kExtmarkUndo); } check_cursor_col(); @@ -1711,7 +1709,7 @@ static inline void pbyte(pos_T lp, int c) assert(c <= UCHAR_MAX); *(ml_get_buf(curbuf, lp.lnum, true) + lp.col) = (char_u)c; if (!curbuf_splice_pending) { - extmark_splice(curbuf, (int)lp.lnum-1, lp.col, 0, 1, 0, 1, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lp.lnum-1, lp.col, 1, 1, kExtmarkUndo); } } @@ -2399,9 +2397,8 @@ int op_change(oparg_T *oap) oldp += bd.textcol; STRMOVE(newp + offset, oldp); ml_replace(linenr, newp, false); - extmark_splice(curbuf, (int)linenr-1, bd.textcol, - 0, 0, - 0, vpos.coladd+(int)ins_len, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)linenr-1, bd.textcol, + 0, vpos.coladd+(int)ins_len, kExtmarkUndo); } } check_cursor(); @@ -3182,10 +3179,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) assert(columns >= 0); memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns); ml_replace(curwin->w_cursor.lnum, newp, false); - extmark_splice(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol, - 0, delcount, - 0, (int)totlen, - kExtmarkUndo); + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol, + delcount, (int)totlen, kExtmarkUndo); ++curwin->w_cursor.lnum; if (i == 0) @@ -3309,9 +3304,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) ++curwin->w_cursor.col; changed_bytes(lnum, col); - extmark_splice(curbuf, (int)lnum-1, col, - 0, 0, - 0, (int)totlen, kExtmarkUndo); + extmark_splice_cols(curbuf, (int)lnum-1, col, + 0, (int)totlen, kExtmarkUndo); } else { // Insert at least one line. When y_type is kMTCharWise, break the first // line in two. |