On Di, 11 Apr 2017, Bram Moolenaar wrote:
> Unnamed register only contains the last deleted text when appending deleted
> text to a register. (Wolfgang Jeltsch, reproduced by Ben Fritz, 2017 Apr 10)

Here is a patch. The problem is, that in op_delete() we are 
unconditionally resetting y_previous to point to register 1. This 
shouldn't happen, if we are appending to an existing register.

I added a test, so that the behaviour can be verified.

Best,
Christian
-- 
Wir haben nicht mehr Recht, Glück zu empfangen, ohne es zu schaffen,
als Reichtum zu genießen, ohne ihn zu produzieren.
                -- George Bernard Shaw

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 48bc81410955428b4b866cc53692fc62cd35de69 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Tue, 27 Jun 2017 10:43:32 +0200
Subject: [PATCH] fix deleting using upper case reg correctly stored in reg "

This fixes the issue, that the "Add would clear the unnamed register.
This happened, because in op_delete() we unconditionally set y_previous
to register 1, although this should probably only happen, if we are not
appending.

Add a test to verify the behaviour.

Fixes https://groups.google.com/d/msg/vim_dev/p-iHvlpVkCM/2xJjLXHdFAAJ
and https://vi.stackexchange.com/questions/11861
---
 src/ops.c                |  4 +++-
 src/testdir/test_put.vim | 11 +++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/ops.c b/src/ops.c
index 237a70488..149938bf6 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1636,7 +1636,9 @@ shift_delete_registers()
     free_yank_all();			/* free register nine */
     for (n = 9; n > 1; --n)
 	y_regs[n] = y_regs[n - 1];
-    y_previous = y_current = &y_regs[1];
+    y_current = &y_regs[1];
+    if (!y_append)
+	y_previous = y_current;
     y_regs[1].y_array = NULL;		/* set register one to empty */
 }
 
diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim
index 38c812bc9..18c7f4e64 100644
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -34,3 +34,14 @@ func Test_put_char_block2()
   bw!
   call setreg('a', a[0], a[1])
 endfunc
+
+func Test_put_lines()
+  new
+  let a = [ getreg('a'), getregtype('a') ]
+  call setline(1, ['Line 1', 'Line2', 'Line 3', ''])
+  exe 'norm! gg"add"AddG""p'
+  call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1,'$'))
+  " clean up
+  bw!
+  call setreg('a', a[0], a[1])
+endfunc
-- 
2.11.0

Raspunde prin e-mail lui