patch 9.1.2082: modeless auto-select not working

Commit: 
https://github.com/vim/vim/commit/92ff4d615d761053e3687d4df7b0dd51e01c3ec3
Author: Foxe Chen <[email protected]>
Date:   Tue Jan 13 20:15:07 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/clipboard.c b/src/clipboard.c
index d016ee3ca..ae80ab42e 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -890,7 +890,7 @@ clip_process_selection(
        printf("Selection ended: (%ld,%d) to (%ld,%d)
", 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);
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 4ebfbfc5e..7cf8a10ae 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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;
 
diff --git a/src/mouse.c b/src/mouse.c
index d11491005..84b8808df 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -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;
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index 7635245b3..3837837be 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -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!
diff --git a/src/testdir/test_modeless.vim b/src/testdir/test_modeless.vim
index ef597ada1..d21df62ab 100644
--- a/src/testdir/test_modeless.vim
+++ b/src/testdir/test_modeless.vim
@@ -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)
diff --git a/src/version.c b/src/version.c
index 126e1cf77..60c86985b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2082,
 /**/
     2081,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vfl1f-00BRb5-NY%40256bit.org.

Raspunde prin e-mail lui