summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnie Rael <errael@raelity.com>2022-07-26 14:44:36 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-26 14:44:36 +0100
commit559f230fd618e51d7986d87217ff38a2eac73cef (patch)
treead8c3ddb592fe3996bd89085dce747676b7152b0
parentb03950fafa07e8b8d975eeb345ad08b8b62e67ce (diff)
downloadvim-git-559f230fd618e51d7986d87217ff38a2eac73cef.tar.gz
patch 9.0.0078: star register is unexpectedly changed when deletingv9.0.0078
Problem: Star register is changed when deleting and both "unnamed" and "unnamedplus" are in 'clipboard'. Solution: Make the use of the star register work as documented. (Ernie Rael, closes #10669)
-rw-r--r--src/register.c5
-rw-r--r--src/testdir/check.vim9
-rw-r--r--src/testdir/test_registers.vim30
-rw-r--r--src/version.c2
4 files changed, 45 insertions, 1 deletions
diff --git a/src/register.c b/src/register.c
index 9a5e11b9c..836273f7c 100644
--- a/src/register.c
+++ b/src/register.c
@@ -1409,7 +1409,8 @@ op_yank(oparg_T *oap, int deleting, int mess)
# ifdef FEAT_X11
// If we were yanking to the '+' register, send result to selection.
// Also copy to the '*' register, in case auto-select is off. But not when
- // 'clipboard' has "unnamedplus" and not "unnamed".
+ // 'clipboard' has "unnamedplus" and not "unnamed"; and not when
+ // deleting and both "unnamedplus" and "unnamed".
if (clip_plus.available
&& (curr == &(y_regs[PLUS_REGISTER])
|| (!deleting && oap->regname == 0
@@ -1425,6 +1426,8 @@ op_yank(oparg_T *oap, int deleting, int mess)
if (!clip_isautosel_star()
&& !clip_isautosel_plus()
&& !((clip_unnamed | clip_unnamed_saved) == CLIP_UNNAMED_PLUS)
+ && !(deleting && (clip_unnamed | clip_unnamed_saved)
+ == (CLIP_UNNAMED | CLIP_UNNAMED_PLUS))
&& !did_star
&& curr == &(y_regs[PLUS_REGISTER]))
{
diff --git a/src/testdir/check.vim b/src/testdir/check.vim
index d64e8457b..c4dca0b78 100644
--- a/src/testdir/check.vim
+++ b/src/testdir/check.vim
@@ -233,6 +233,15 @@ func CheckX11BasedGui()
endif
endfunc
+" Command to check that there are two clipboards
+command CheckTwoClipboards call CheckTwoClipboards()
+func CheckTwoClipboards()
+ " avoid changing the clipboard here, only X11 supports both
+ if !has('X11')
+ throw 'Skipped: requires two clipboards'
+ endif
+endfunc
+
" Command to check for satisfying any of the conditions.
" e.g. CheckAnyOf Feature:bsd Feature:sun Linux
command -nargs=+ CheckAnyOf call CheckAnyOf(<f-args>)
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
index 352264981..35bd1e0a3 100644
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -411,6 +411,36 @@ func Test_clipboard_regs()
bwipe!
endfunc
+" Test unnamed for both clipboard registers (* and +)
+func Test_clipboard_regs_both_unnamed()
+ CheckNotGui
+ CheckFeature clipboard_working
+ CheckTwoClipboards
+
+ let @* = 'xxx'
+ let @+ = 'xxx'
+
+ new
+
+ set clipboard=unnamed,unnamedplus
+ call setline(1, ['foo', 'bar'])
+
+ " op_yank copies to both
+ :1
+ :normal yw
+ call assert_equal('foo', getreg('*'))
+ call assert_equal('foo', getreg('+'))
+
+ " op_delete only copies to '+'
+ :2
+ :normal dw
+ call assert_equal('foo', getreg('*'))
+ call assert_equal('bar', getreg('+'))
+
+ set clipboard&vim
+ bwipe!
+endfunc
+
" Test for restarting the current mode (insert or virtual replace) after
" executing the contents of a register
func Test_put_reg_restart_mode()
diff --git a/src/version.c b/src/version.c
index 08039d9eb..a7fe96c94 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 78,
+/**/
77,
/**/
76,