diff src/register.c @ 24752:1ce39e257f1b v8.2.2914

patch 8.2.2914: cannot paste a block without adding padding Commit: https://github.com/vim/vim/commit/2fa9384ca1b600b934bec81a72c5fb7ce757503a Author: Christian Brabandt <cb@256bit.org> Date: Sun May 30 22:17:25 2021 +0200 patch 8.2.2914: cannot paste a block without adding padding Problem: Cannot paste a block without adding padding. Solution: Add "zp" and "zP" which paste without adding padding. (Christian Brabandt, closes #8289)
author Bram Moolenaar <Bram@vim.org>
date Sun, 30 May 2021 22:30:03 +0200
parents 580ee78577e9
children 14b86681e6e6
line wrap: on
line diff
--- a/src/register.c
+++ b/src/register.c
@@ -1497,6 +1497,7 @@ copy_yank_reg(yankreg_T *reg)
  * "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
  */
     void
 do_put(
@@ -1794,7 +1795,7 @@ do_put(
 	bd.textcol = 0;
 	for (i = 0; i < y_size; ++i)
 	{
-	    int spaces;
+	    int spaces = 0;
 	    char shortline;
 
 	    bd.startspaces = 0;
@@ -1845,12 +1846,16 @@ do_put(
 
 	    yanklen = (int)STRLEN(y_array[i]);
 
-	    // calculate number of spaces required to fill right side of block
-	    spaces = y_width + 1;
-	    for (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 (j = 0; j < yanklen; j++)
+		    spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0);
+		if (spaces < 0)
+		    spaces = 0;
+	    }
 
 	    // insert the new text
 	    totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;