diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-03-24 00:27:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 00:27:55 +0100 |
commit | 1186f7dd96b054d6a653685089fc845a8f5d2f27 (patch) | |
tree | 11b475bb721cc6ea74552c7d71bb3d614cee022b /src/nvim/ops.c | |
parent | 9f5c8226bba43b6c9ae253e6b94b41d9d140a626 (diff) | |
parent | 7fbabbaa576cd3e1de303d6040b1c8444d5708a7 (diff) | |
download | rneovim-1186f7dd96b054d6a653685089fc845a8f5d2f27.tar.gz rneovim-1186f7dd96b054d6a653685089fc845a8f5d2f27.tar.bz2 rneovim-1186f7dd96b054d6a653685089fc845a8f5d2f27.zip |
Merge pull request #14191 from chentau/extmark_blockpaste
Extmarks: send correct buffer events on blockwise paste for nonuniform lines
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3038fad894..0ff427c261 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3177,7 +3177,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) // insert the new text totlen = (size_t)(count * (yanklen + spaces) + bd.startspaces + bd.endspaces); - newp = (char_u *) xmalloc(totlen + oldlen + 1); + int addcount = (int)totlen + lines_appended; + newp = (char_u *)xmalloc(totlen + oldlen + 1); // copy part up to cursor to new line ptr = newp; memmove(ptr, oldp, (size_t)bd.textcol); @@ -3194,6 +3195,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if ((j < count - 1 || !shortline) && spaces) { memset(ptr, ' ', (size_t)spaces); ptr += spaces; + } else { + addcount -= spaces; } } // may insert some spaces after the new text @@ -3205,7 +3208,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns); ml_replace(curwin->w_cursor.lnum, newp, false); extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum-1, bd.textcol, - delcount, (int)totlen + lines_appended, kExtmarkUndo); + delcount, addcount, kExtmarkUndo); ++curwin->w_cursor.lnum; if (i == 0) |