patch 9.1.2082: modeless auto-select not working

Problem:  modeless auto-select not working
          (Coacher)
Solution: Add support for modeless autoselect
          (Foxe Chen)

fixes:  #19159
closes: #19168

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2026-01-13 20:15:07 +00:00
committed by Christian Brabandt
parent c2f453f5f3
commit 92ff4d615d
6 changed files with 47 additions and 13 deletions
+16 -11
View File
@@ -890,7 +890,7 @@ clip_process_selection(
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) :
@@ -1119,13 +1119,17 @@ clip_scroll_selection(
}
/*
* 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;
@@ -1297,23 +1301,24 @@ clip_copy_modeless_selection(int both UNUSED)
*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);
+1 -1
View File
@@ -1347,7 +1347,7 @@ cmdline_left_right_mouse(int c, int *ignore_drag_release)
if (!mouse_has(MOUSE_COMMAND))
return;
# ifdef FEAT_CLIPBOARD
if (mouse_row < cmdline_row && clip_star.available)
if (mouse_row < cmdline_row && (clip_star.available || clip_plus.available))
{
int button, is_click, is_drag;
+2 -1
View File
@@ -795,7 +795,8 @@ do_mouse(
#endif
#if defined(FEAT_CLIPBOARD)
if ((jump_flags & IN_OTHER_WIN) && !VIsual_active && clip_star.available)
if ((jump_flags & IN_OTHER_WIN) && !VIsual_active &&
(clip_star.available || clip_plus.available))
{
clip_modeless(which_button, is_click, is_drag);
return FALSE;
+13
View File
@@ -1248,6 +1248,19 @@ func Test_gui_mouse_event()
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!
+13
View File
@@ -219,6 +219,19 @@ func Test_modeless_characterwise_selection()
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)
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2082,
/**/
2081,
/**/