linenr_T yankendlnum = oap->end.lnum;
char_u *pnew;
struct block_def bd;
-#if defined(FEAT_CLIPBOARD) && (defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD))
- int did_star = FALSE;
-#endif
// check for read-only register
if (oap->regname != 0 && !valid_yank_reg(oap->regname, TRUE))
clip_own_selection(&clip_star);
clip_gen_set_selection(&clip_star);
-# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
- did_star = TRUE;
-# endif
}
# if defined(FEAT_X11) || defined(FEAT_WAYLAND_CLIPBOARD)
// 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
clip_own_selection(&clip_plus);
clip_gen_set_selection(&clip_plus);
- 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]))
- {
- copy_yank_reg(&(y_regs[STAR_REGISTER]));
- clip_own_selection(&clip_star);
- clip_gen_set_selection(&clip_star);
- }
}
# endif
#endif
bwipe!
endfunc
+" When clipboard registers (* and +) are supported, check that they are
+" independent for direct writes.
+func Test_clipboard_regs_separate()
+ CheckNotGui
+ CheckFeature clipboard_working
+ CheckTwoClipboards
+
+ new
+ call setline(1, ['foo'])
+
+ " Check that various clipboard options do not result in one register
+ " affecting the other.
+ for clip in ['', 'autoselect', 'unnamed', 'unnamedplus']
+ :execute 'set clipboard=' . clip
+ " check that * does not affect +
+ let @* = 'xxx'
+ let @+ = 'xxx'
+ :normal "*yw
+ call assert_equal('foo', getreg('*'))
+ call assert_equal('xxx', getreg('+'))
+
+ " check that + does not affect *
+ let @* = 'xxx'
+ :normal "+yw
+ call assert_equal('foo', getreg('+'))
+ call assert_equal('xxx', getreg('*'))
+ endfor
+
+ set clipboard&vim
+ bwipe!
+endfunc
+
" Test unnamed for both clipboard registers (* and +)
func Test_clipboard_regs_both_unnamed()
CheckNotGui