diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-31 22:01:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 22:01:09 -0400 |
commit | 27c616d688c73c406726c949a3b664f52d4e4f04 (patch) | |
tree | 9c668b6cc67d0592b6744f2a8b227c80c2b1cded /src/nvim/ops.c | |
parent | e8f0ff1d48f5e85c0e16f0a248ff1781d4d080b3 (diff) | |
parent | c3ac9c13dffaa79827602536519bc64d65689d05 (diff) | |
download | rneovim-27c616d688c73c406726c949a3b664f52d4e4f04.tar.gz rneovim-27c616d688c73c406726c949a3b664f52d4e4f04.tar.bz2 rneovim-27c616d688c73c406726c949a3b664f52d4e4f04.zip |
Merge pull request #14685 from janlazo/vim-8.2.2911
vim-patch:8.1.2400,8.2.{2911,2914.2916}
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 0ed116c17f..2c8c7f0567 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2788,13 +2788,13 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) recursive = false; } -/* - * Put contents of register "regname" into the text. - * Caller must check "regname" to be valid! - * "flags": PUT_FIXINDENT make indent look nice - * PUT_CURSEND leave cursor after end of new text - * PUT_LINE force linewise put (":put") - dir: BACKWARD for 'P', FORWARD for 'p' */ +// Put contents of register "regname" into the text. +// Caller must check "regname" to be valid! +// "flags": PUT_FIXINDENT make indent look nice +// PUT_CURSEND leave cursor after end of new text +// PUT_LINE force linewise put (":put") +// PUT_BLOCK_INNER in block mode, do not add trailing spaces +// dir: BACKWARD for 'P', FORWARD for 'p' void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) { char_u *ptr; @@ -3126,7 +3126,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) curwin->w_cursor.coladd = 0; bd.textcol = 0; for (i = 0; i < y_size; i++) { - int spaces; + int spaces = 0; char shortline; // can just be 0 or 1, needed for blockwise paste beyond the current // buffer end @@ -3177,13 +3177,16 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) yanklen = (int)STRLEN(y_array[i]); - // calculate number of spaces required to fill right side of block - spaces = y_width + 1; - for (long j = 0; j < yanklen; j++) { - spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); - } - if (spaces < 0) { - spaces = 0; + if ((flags & PUT_BLOCK_INNER) == 0) { + // calculate number of spaces required to fill right side of + // block + spaces = y_width + 1; + for (int j = 0; j < yanklen; j++) { + spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); + } + if (spaces < 0) { + spaces = 0; + } } // insert the new text |