]> granicus.if.org Git - vim/commitdiff
patch 8.0.0724: the message for yanking doesn't indicate the register v8.0.0724
authorBram Moolenaar <Bram@vim.org>
Sun, 16 Jul 2017 15:56:16 +0000 (17:56 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 16 Jul 2017 15:56:16 +0000 (17:56 +0200)
Problem:    The message for yanking doesn't indicate the register.
Solution:   Show the register name in the "N lines yanked" message. (Lemonboy,
            closes #1803, closes #1809)

src/Makefile
src/ops.c
src/testdir/Make_all.mak
src/testdir/test_registers.vim [new file with mode: 0644]
src/version.c

index 6c236ca7166e41c670bea0cc4e5a5d9614c50602..80265fd5b2e582d05075f75f61b04e5ad5193ec7 100644 (file)
@@ -2227,6 +2227,7 @@ test_arglist \
        test_regex_char_classes \
        test_regexp_latin \
        test_regexp_utf8 \
+       test_registers \
        test_reltime \
        test_retab \
        test_ruby \
index 2aec5d4383bf0e4a122b07853052eed880734d0d..05ccc8114cf20cd38b5add55c0c603adcacc8cd9 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -3167,19 +3167,29 @@ op_yank(oparg_T *oap, int deleting, int mess)
        /* Some versions of Vi use ">=" here, some don't...  */
        if (yanklines > p_report)
        {
+           char namebuf[100];
+
+           if (oap->regname == NUL)
+               *namebuf = NUL;
+           else
+               vim_snprintf(namebuf, sizeof(namebuf),
+                                                  " into \"%c", oap->regname);
+
            /* redisplay now, so message is not deleted */
            update_topline_redraw();
            if (yanklines == 1)
            {
                if (oap->block_mode)
-                   MSG(_("block of 1 line yanked"));
+                   smsg((char_u *)_("block of 1 line yanked%s"), namebuf);
                else
-                   MSG(_("1 line yanked"));
+                   smsg((char_u *)_("1 line yanked%s"), namebuf);
            }
            else if (oap->block_mode)
-               smsg((char_u *)_("block of %ld lines yanked"), yanklines);
+               smsg((char_u *)_("block of %ld lines yanked%s"),
+                    yanklines, namebuf);
            else
-               smsg((char_u *)_("%ld lines yanked"), yanklines);
+               smsg((char_u *)_("%ld lines yanked%s"), yanklines,
+                    namebuf);
        }
     }
 
index 217a295472d05bb0114240ab3a950f6eeed6b8af..16068816e0c28a26708ada6ef4f0198664fb1580 100644 (file)
@@ -184,6 +184,7 @@ NEW_TESTS = test_arabic.res \
            test_quickfix.res \
            test_quotestar.res \
            test_retab.res \
+           test_registers.res \
            test_ruby.res \
            test_search.res \
            test_signs.res \
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
new file mode 100644 (file)
index 0000000..912a5c7
--- /dev/null
@@ -0,0 +1,27 @@
+
+func Test_yank_shows_register()
+    enew
+    set report=0
+    call setline(1, ['foo', 'bar'])
+    " Line-wise
+    exe 'norm! yy'
+    call assert_equal('1 line yanked', v:statusmsg)
+    exe 'norm! "zyy'
+    call assert_equal('1 line yanked into "z', v:statusmsg)
+    exe 'norm! yj'
+    call assert_equal('2 lines yanked', v:statusmsg)
+    exe 'norm! "zyj'
+    call assert_equal('2 lines yanked into "z', v:statusmsg)
+
+    " Block-wise
+    exe "norm! \<C-V>y"
+    call assert_equal('block of 1 line yanked', v:statusmsg)
+    exe "norm! \<C-V>\"zy"
+    call assert_equal('block of 1 line yanked into "z', v:statusmsg)
+    exe "norm! \<C-V>jy"
+    call assert_equal('block of 2 lines yanked', v:statusmsg)
+    exe "norm! \<C-V>j\"zy"
+    call assert_equal('block of 2 lines yanked into "z', v:statusmsg)
+
+    bwipe!
+endfunc
index 1b2cc8a956f802f8a4574ab19d71e7c54add640f..e8e2e059e85eb31db6c74295538cb05ecb00e106 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    724,
 /**/
     723,
 /**/