Patch 9.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)
Files: src/register.c, src/testdir/check.vim,
src/testdir/test_registers.vim
*** ../vim-9.0.0077/src/register.c 2022-07-25 18:13:33.054580717 +0100
--- src/register.c 2022-07-26 14:43:49.861775797 +0100
***************
*** 1409,1415 ****
# 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".
if (clip_plus.available
&& (curr == &(y_regs[PLUS_REGISTER])
|| (!deleting && oap->regname == 0
--- 1409,1416 ----
# 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"; and not when
! // deleting and both "unnamedplus" and "unnamed".
if (clip_plus.available
&& (curr == &(y_regs[PLUS_REGISTER])
|| (!deleting && oap->regname == 0
***************
*** 1425,1430 ****
--- 1426,1433 ----
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]))
{
*** ../vim-9.0.0077/src/testdir/check.vim 2022-06-21 18:29:32.000000000 +0100
--- src/testdir/check.vim 2022-07-26 14:43:05.705884195 +0100
***************
*** 233,238 ****
--- 233,247 ----
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>)
*** ../vim-9.0.0077/src/testdir/test_registers.vim 2022-04-09 17:57:50.000000000 +0100
--- src/testdir/test_registers.vim 2022-07-26 14:37:16.110844020 +0100
***************
*** 411,416 ****
--- 411,446 ----
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()
*** ../vim-9.0.0077/src/version.c 2022-07-26 13:46:53.603727842 +0100
--- src/version.c 2022-07-26 14:40:29.070289026 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 78,
/**/
--
There are three kinds of persons: Those who can count and those who can't.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///