]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1322: small delete register cannot paste multi-line correctly v9.1.1322
authorphanium <91544758+phanen@users.noreply.github.com>
Fri, 18 Apr 2025 16:32:52 +0000 (18:32 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 18 Apr 2025 16:32:52 +0000 (18:32 +0200)
Problem:  small delete register cannot paste multi-line correctly
          (after v8.2.2189)
Solution: caused by 032a2d050b82b146d70d6ff714838ee62c07d8ad, so make
          this logic handle charwise only (phanium)

closes: #17151

Signed-off-by: phanium <91544758+phanen@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/register.c
src/testdir/test_registers.vim
src/version.c

index 267e0fcc43348d9d7610493fd8c110a31596f3f3..9d27706698cf943775abfb328b4769e77b5e7020 100644 (file)
@@ -846,7 +846,7 @@ insert_reg(
        {
            for (i = 0; i < y_current->y_size; ++i)
            {
-               if (regname == '-')
+               if (regname == '-' && y_current->y_type == MCHAR)
                {
                    int dir = BACKWARD;
                    if ((State & REPLACE_FLAG) != 0)
@@ -867,11 +867,13 @@ insert_reg(
                    do_put(regname, NULL, dir, 1L, PUT_CURSEND);
                }
                else
+               {
                    stuffescaped(y_current->y_array[i].string, literally);
-               // Insert a newline between lines and after last line if
-               // y_type is MLINE.
-               if (y_current->y_type == MLINE || i < y_current->y_size - 1)
-                   stuffcharReadbuff('\n');
+                   // Insert a newline between lines and after last line if
+                   // y_type is MLINE.
+                   if (y_current->y_type == MLINE || i < y_current->y_size - 1)
+                       stuffcharReadbuff('\n');
+               }
            }
        }
     }
index 981f9d227e89866fca5356d50a166903b7ff5eb7..b597ab326eb751eae01e828d77200d831f054b5f 100644 (file)
@@ -1204,4 +1204,13 @@ func Test_mark_from_yank()
   bw!
 endfunc
 
+func Test_insert_small_delete_linewise()
+  new
+  call setline(1, ['foo'])
+  call cursor(1, 1)
+  exe ":norm! \"-cc\<C-R>-"
+  call assert_equal(['foo', ''], getline(1, '$'))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 4c9f4ce53d668a8fa72a1b56a60a80ebe2d59409..4990e4475ccb4c64308d5d526bf9a7aee3ceb31a 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1322,
 /**/
     1321,
 /**/