]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2114: modeless selection not copied to * register master v9.1.2114
authorFoxe Chen <chen.foxe@gmail.com>
Thu, 29 Jan 2026 19:10:51 +0000 (19:10 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 29 Jan 2026 19:18:10 +0000 (19:18 +0000)
Problem:  modeless selection not copied to * register when P in
          guioptions (Coacher)
Solution: Make the "P" flag override the "a" and "A" flag
          (Foxe Chen)

fixes:  #19187
closes: #19244

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
src/clipboard.c
src/testdir/test_gui.vim
src/version.c

index fb94aec4dab0585616fde4c4dec65632576f2242..cdb75dae2a4e4de643394241ff1ffabd372a89d1 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2026 Jan 28
+*options.txt*  For Vim version 9.1.  Last change: 2026 Jan 29
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -4515,8 +4515,8 @@ A jump table for the options with a short description can be found at |Q_op|.
                by a yank or delete operation for the "* register.
                The same applies to the modeless selection.
                                                                *'go-P'*
-         'P'   Like autoselect but using the "+ register instead of the "*
-               register.
+         'P'   Like autoselect but only copy to the "+ register instead of
+               the "* register.
                                                                *'go-A'*
          'A'   Autoselect for the modeless selection.  Like 'a', but only
                applies to the modeless selection.
index 8cf62cf88b5217caa262aae4bc39fb27a1c70454..6a0473b0ae87c703a03fa85992e13a8d9dc54d7f 100644 (file)
@@ -452,11 +452,12 @@ clip_auto_select(void)
     int
 clip_isautosel_star(void)
 {
-    return (
-# ifdef FEAT_GUI
-           gui.in_use ? (vim_strchr(p_go, GO_ASEL) != NULL) :
-# endif
-           clip_autoselect_star);
+#ifdef FEAT_GUI
+    if (gui.in_use)
+       return vim_strchr(p_go, GO_ASEL) != NULL
+           && vim_strchr(p_go, GO_ASELPLUS) == NULL;
+#endif
+    return clip_autoselect_star;
 }
 
 /*
@@ -466,11 +467,11 @@ clip_isautosel_star(void)
     int
 clip_isautosel_plus(void)
 {
-    return (
-# ifdef FEAT_GUI
-           gui.in_use ? (vim_strchr(p_go, GO_ASELPLUS) != NULL) :
-# endif
-           clip_autoselect_plus);
+#ifdef FEAT_GUI
+    if (gui.in_use)
+       return vim_strchr(p_go, GO_ASELPLUS) != NULL;
+#endif
+    return clip_autoselect_plus;
 }
 
 
index 3837837be7ee77f4f7dd6bab86781651ba3e9b60..67b0500aa656dbd446922d9ab86f1b757be3303c 100644 (file)
@@ -1827,4 +1827,38 @@ func Test_Buffers_Menu()
   %bw!
 endfunc
 
+" Test if 'guioptions=a' only copies to the primary selection and
+" 'guioptions=aP' only copies to the regular selection.
+func Test_guioptions_clipboard()
+  CheckX11BasedGui
+
+  set mouse=
+  let save_guioptions = &guioptions
+  set guioptions=a
+
+  let @+ = ""
+  let @* = ""
+
+  call setline(1, ['one two three', 'four five six'])
+  call cursor(1, 1)
+  call feedkeys("\<Esc>vee\<Esc>", "Lx!")
+
+  call assert_equal("one two", @*)
+  call assert_equal("", @+)
+
+  set guioptions=aP
+
+  let @+ = ""
+  let @* = ""
+
+  call cursor(1, 1)
+  call feedkeys("\<Esc>veee\<Esc>", "Lx!")
+
+  call assert_equal("one two three", @+)
+  call assert_equal("", @*)
+
+  set mouse&
+  let &guioptions = save_guioptions
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index f79353e517afbd925a9829541b19f1174abfa03e..a885fd23d46d35a8971cfc65c57629e060c9b847 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2114,
 /**/
     2113,
 /**/