printf("Selection ended: (%ld,%d) to (%ld,%d)\n", cb->start.lnum,
cb->start.col, cb->end.lnum, cb->end.col);
#endif
- if (clip_isautosel_star()
+ if (clip_isautosel_star() || clip_isautosel_plus()
|| (
#ifdef FEAT_GUI
gui.in_use ? (vim_strchr(p_go, GO_ASELML) != NULL) :
}
/*
- * Copy the currently selected area into the '*' register so it will be
+ * Copy the currently selected area into the '*' or '+' register so it will be
* available for pasting.
- * When "both" is TRUE also copy to the '+' register.
+ * When "both" is TRUE also copy to the other register.
*/
void
clip_copy_modeless_selection(int both UNUSED)
{
+ // The info for the modeless selection is stored in '*' register, however if
+ // we are using the '+' register for modeless autoselect, we copy to
+ // clip_plus instead while using the info in clip_star.
+ Clipboard_T *cbd = clip_isautosel_plus() ? &clip_plus : &clip_star;
char_u *buffer;
char_u *bufp;
int row;
*bufp++ = NL;
// First cleanup any old selection and become the owner.
- clip_free_selection(&clip_star);
- clip_own_selection(&clip_star);
+ clip_free_selection(cbd);
+ clip_own_selection(cbd);
// Yank the text into the '*' register.
- clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), &clip_star);
+ clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), cbd);
// Make the register contents available to the outside world.
- clip_gen_set_selection(&clip_star);
+ clip_gen_set_selection(cbd);
#ifdef FEAT_X11
if (both)
{
+ Clipboard_T *other = cbd == &clip_star ? &clip_plus : &clip_star;
// Do the same for the '+' register.
- clip_free_selection(&clip_plus);
- clip_own_selection(&clip_plus);
- clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), &clip_plus);
- clip_gen_set_selection(&clip_plus);
+ clip_free_selection(other);
+ clip_own_selection(other);
+ clip_yank_selection(MCHAR, buffer, (long)(bufp - buffer), other);
+ clip_gen_set_selection(other);
}
#endif
vim_free(buffer);
call assert_equal([0, 2, 7, 0], getpos('.'))
call assert_equal('wo thrfour five sixteen', getline(2))
+ " Test P option (use '+' register for modeless)
+ set guioptions+=AP
+ call cursor(1, 6)
+ redraw!
+ let @+ = ''
+ let args = #{button: 2, row: 1, col: 11, multiclick: 0, modifiers: 0}
+ call test_gui_event('mouse', args)
+ let args.button = 3
+ call test_gui_event('mouse', args)
+ call feedkeys("\<Esc>", 'Lx!')
+ call assert_equal([0, 1, 6, 0], getpos('.'))
+ call assert_equal('wo thr', @+)
+
set mouse&
let &guioptions = save_guioptions
bw!
call assert_equal("bar", @*)
set clipboard&
+ " Test for 'clipboard' set to 'autoselectplus' to automatically copy the
+ " modeless selection to the '+' clipboard.
+ set clipboard=autoselectplus
+ let @* = 'clean'
+ let keys = ":"
+ let keys ..= MouseLeftClickCode(2, 5)
+ let keys ..= MouseLeftDragCode(2, 7)
+ let keys ..= MouseLeftReleaseCode(2, 7)
+ let keys ..= "\<CR>"
+ call feedkeys(keys, "x")
+ call assert_equal("bar", @+)
+ set clipboard&
+
" quadruple click should start characterwise selectmode
let @* = 'clean'
call MouseRightClick(1, 1)