diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-08-22 18:34:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-22 18:34:52 -0400 |
commit | 8c49e3d50959e24dadd688f56a18f104bd5fd934 (patch) | |
tree | e75e6d0435ce10e9df427c5b11e943127dad0983 /src/nvim/ops.c | |
parent | 161cdba1e3b8b53f474b2e76655c8c1a5217802f (diff) | |
parent | 246c510b6022b7155c9b78767c41094df7cb2be8 (diff) | |
download | rneovim-8c49e3d50959e24dadd688f56a18f104bd5fd934.tar.gz rneovim-8c49e3d50959e24dadd688f56a18f104bd5fd934.tar.bz2 rneovim-8c49e3d50959e24dadd688f56a18f104bd5fd934.zip |
Merge pull request #12770 from janlazo/vim-8.1.1115
vim-patch:8.1.{1115,2267},8.2.{607,814,1472,1474,1476,1511}
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 595a699563..d31328219f 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3238,21 +3238,43 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) --lnum; new_cursor = curwin->w_cursor; - // simple case: insert into current line + // simple case: insert into one line at a time if (y_type == kMTCharWise && y_size == 1) { linenr_T end_lnum = 0; // init for gcc + linenr_T start_lnum = lnum; if (VIsual_active) { end_lnum = curbuf->b_visual.vi_end.lnum; if (end_lnum < curbuf->b_visual.vi_start.lnum) { end_lnum = curbuf->b_visual.vi_start.lnum; } + if (end_lnum > start_lnum) { + // "col" is valid for the first line, in following lines + // the virtual column needs to be used. Matters for + // multi-byte characters. + pos_T pos = { + .lnum = lnum, + .col = col, + .coladd = 0, + }; + getvcol(curwin, &pos, NULL, &vcol, NULL); + } } do { totlen = (size_t)(count * yanklen); if (totlen > 0) { oldp = ml_get(lnum); + if (lnum > start_lnum) { + pos_T pos = { + .lnum = lnum, + }; + if (getvpos(&pos, vcol) == OK) { + col = pos.col; + } else { + col = MAXCOL; + } + } if (VIsual_active && col > (int)STRLEN(oldp)) { lnum++; continue; |