]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1863: Cannot test for working "+" register v9.1.1863
authorFoxe Chen <chen.foxe@gmail.com>
Thu, 16 Oct 2025 19:11:37 +0000 (19:11 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 16 Oct 2025 19:11:37 +0000 (19:11 +0000)
Problem:  Cannot test for working "+" register
Solution: Add a few more feature tests (Foxe Chen)

closes: #18541

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

index 787e59ed88bcda8e9f5ae427717c5e9b04a3232c..6a53471f9c5a48e243bc8568a46a95a7fcd4a0b8 100644 (file)
@@ -1411,7 +1411,9 @@ $quote    eval.txt        /*$quote*
 +cindent       various.txt     /*+cindent*
 +clientserver  various.txt     /*+clientserver*
 +clipboard     various.txt     /*+clipboard*
++clipboard_plus_avail  various.txt     /*+clipboard_plus_avail*
 +clipboard_provider    various.txt     /*+clipboard_provider*
++clipboard_star_avail  various.txt     /*+clipboard_star_avail*
 +clipboard_working     various.txt     /*+clipboard_working*
 +cmd   editing.txt     /*+cmd*
 +cmdline_compl various.txt     /*+cmdline_compl*
index 78777eef52a3132733f91b714d9f722a9b48d29d..c7ed02764bb1fe076c33cbfb1d2a2799297b072b 100644 (file)
@@ -1,4 +1,4 @@
-*various.txt*   For Vim version 9.1.  Last change: 2025 Oct 14
+*various.txt*   For Vim version 9.1.  Last change: 2025 Oct 16
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -380,6 +380,12 @@ N  *+clientserver* Unix and Win32: Remote invocation |clientserver|
    *+clipboard*                |clipboard| support compiled-in
 N  *+clipboard_provider*  |clipboard-providers| support compiled-in
    *+clipboard_working*        |clipboard| support compiled-in and working
+   *+clipboard_star_avail*
+                       |clipboard| support compiled-in and star "*" register
+                       available
+   *+clipboard_plus_avail*
+                       |clipboard| support compiled-in and separate plus "+"
+                       register available
 T  *+cmdline_compl*    command line completion |cmdline-completion|
 T  *+cmdline_hist*     command line history |cmdline-history|
 T  *+cmdline_info*     'showcmd' and 'ruler'; Always enabled since
index f289879dd56d5f37bec662ce25f58d3a5208cf5c..e51138669037275d131b962f720ce86f27e3256c 100644 (file)
@@ -3573,7 +3573,6 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star)
 #endif
                *star = star_avail == 1;
            }
-
            else if (
 #ifndef ONE_CLIPBOARD
                    plus_avail == -1 ||
@@ -3585,7 +3584,6 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star)
                goto exit;
            }
        }
-
        // Keep on going in order to catch errors
        if (method != CLIPMETHOD_NONE && ret == CLIPMETHOD_FAIL)
            ret = method;
index e2e9bcbef94d92042aaf2ebf4f674e83260390cd..17e7adbcb6d0984fd414b68a3136e2a0e6bb63dc 100644 (file)
@@ -7929,8 +7929,22 @@ f_has(typval_T *argvars, typval_T *rettv)
        else if (STRICMP(name, "clipboard_working") == 0)
        {
            x = TRUE;
+#ifdef FEAT_CLIPBOARD
+           n = clip_star.available || clip_plus.available;
+#endif
+       }
+       else if (STRICMP(name, "clipboard_star_avail") == 0)
+       {
+           x = TRUE;
 #ifdef FEAT_CLIPBOARD
            n = clip_star.available;
+#endif
+       }
+       else if (STRICMP(name, "clipboard_plus_avail") == 0)
+       {
+           x = TRUE;
+#ifdef FEAT_CLIPBOARD
+           n = clip_plus.available && &clip_star != &clip_plus;
 #endif
        }
     }
index 39bb4ba9f2d08305420511511a232fcef6d5ab16..0e5c7e9230d17b112a6da9f92304c0584ccbc231 100644 (file)
@@ -727,4 +727,48 @@ func Test_eval_string_in_special_key()
   silent! echo 0{1-$"\<S--{>\17n|nö%\0
 endfunc
 
+func AvailableTest()
+  return g:vim_test_plus .. g:vim_test_star
+endfunc
+
+func Test_clipboard_runtime_features()
+  " Use clipboard provider because we can change if a register is available or
+  " not.
+  CheckFeature clipboard_provider
+  CheckFeature clipboard
+
+    let g:vim_test_plus = ''
+    let g:vim_test_star = ''
+
+  let v:clipproviders["evaltest"] = {
+        \ "available": function("AvailableTest")
+        \ }
+
+  set clipmethod=evaltest
+
+  if has('win32') || has('macunix')
+    let g:vim_test_plus = '+'
+    let g:vim_test_star = '*'
+    clipreset
+
+    " plus register should be disabled on windows or macos
+    call assert_equal(0, has('clipboard_plus_avail'))
+    call assert_equal(1, has('clipboard_star_avail'))
+  else
+    let g:vim_test_plus = '+'
+    let g:vim_test_star = '*'
+    clipreset
+
+    call assert_equal(1, has('clipboard_plus_avail'))
+    call assert_equal(1, has('clipboard_star_avail'))
+
+    let g:vim_test_plus = ""
+    clipreset
+
+    call assert_equal(0, has('clipboard_plus_avail'))
+  endif
+
+  set clipmethod&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 969ac9cc97296855794bb4019d7f993ec31a6ca9..9e05de8a31a53b35205dd9c048008c23fb7faaf3 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1863,
 /**/
     1862,
 /**/