Skip to content

Commit f22cedd

Browse files
64-bitmanchrisbra
authored andcommitted
patch 9.1.1863: Cannot test for working "+" register
Problem: Cannot test for working "+" register Solution: Add a few more feature tests (Foxe Chen) closes: #18541 Signed-off-by: Foxe Chen <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 18d57a1 commit f22cedd

6 files changed

Lines changed: 69 additions & 3 deletions

File tree

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,9 @@ $quote eval.txt /*$quote*
14111411
+cindent various.txt /*+cindent*
14121412
+clientserver various.txt /*+clientserver*
14131413
+clipboard various.txt /*+clipboard*
1414+
+clipboard_plus_avail various.txt /*+clipboard_plus_avail*
14141415
+clipboard_provider various.txt /*+clipboard_provider*
1416+
+clipboard_star_avail various.txt /*+clipboard_star_avail*
14151417
+clipboard_working various.txt /*+clipboard_working*
14161418
+cmd editing.txt /*+cmd*
14171419
+cmdline_compl various.txt /*+cmdline_compl*

runtime/doc/various.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*various.txt* For Vim version 9.1. Last change: 2025 Oct 14
1+
*various.txt* For Vim version 9.1. Last change: 2025 Oct 16
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -380,6 +380,12 @@ N *+clientserver* Unix and Win32: Remote invocation |clientserver|
380380
*+clipboard* |clipboard| support compiled-in
381381
N *+clipboard_provider* |clipboard-providers| support compiled-in
382382
*+clipboard_working* |clipboard| support compiled-in and working
383+
*+clipboard_star_avail*
384+
|clipboard| support compiled-in and star "*" register
385+
available
386+
*+clipboard_plus_avail*
387+
|clipboard| support compiled-in and separate plus "+"
388+
register available
383389
T *+cmdline_compl* command line completion |cmdline-completion|
384390
T *+cmdline_hist* command line history |cmdline-history|
385391
T *+cmdline_info* 'showcmd' and 'ruler'; Always enabled since

src/clipboard.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,7 +3573,6 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star)
35733573
#endif
35743574
*star = star_avail == 1;
35753575
}
3576-
35773576
else if (
35783577
#ifndef ONE_CLIPBOARD
35793578
plus_avail == -1 ||
@@ -3585,7 +3584,6 @@ get_clipmethod(char_u *str, bool *plus UNUSED, bool *star)
35853584
goto exit;
35863585
}
35873586
}
3588-
35893587
// Keep on going in order to catch errors
35903588
if (method != CLIPMETHOD_NONE && ret == CLIPMETHOD_FAIL)
35913589
ret = method;

src/evalfunc.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7929,8 +7929,22 @@ f_has(typval_T *argvars, typval_T *rettv)
79297929
else if (STRICMP(name, "clipboard_working") == 0)
79307930
{
79317931
x = TRUE;
7932+
#ifdef FEAT_CLIPBOARD
7933+
n = clip_star.available || clip_plus.available;
7934+
#endif
7935+
}
7936+
else if (STRICMP(name, "clipboard_star_avail") == 0)
7937+
{
7938+
x = TRUE;
79327939
#ifdef FEAT_CLIPBOARD
79337940
n = clip_star.available;
7941+
#endif
7942+
}
7943+
else if (STRICMP(name, "clipboard_plus_avail") == 0)
7944+
{
7945+
x = TRUE;
7946+
#ifdef FEAT_CLIPBOARD
7947+
n = clip_plus.available && &clip_star != &clip_plus;
79347948
#endif
79357949
}
79367950
}

src/testdir/test_eval_stuff.vim

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,4 +727,48 @@ func Test_eval_string_in_special_key()
727727
silent! echo 0{1-$"\<S--{>n|nö%
728728
endfunc
729729

730+
func AvailableTest()
731+
return g:vim_test_plus .. g:vim_test_star
732+
endfunc
733+
734+
func Test_clipboard_runtime_features()
735+
" Use clipboard provider because we can change if a register is available or
736+
" not.
737+
CheckFeature clipboard_provider
738+
CheckFeature clipboard
739+
740+
let g:vim_test_plus = ''
741+
let g:vim_test_star = ''
742+
743+
let v:clipproviders["evaltest"] = {
744+
\ "available": function("AvailableTest")
745+
\ }
746+
747+
set clipmethod=evaltest
748+
749+
if has('win32') || has('macunix')
750+
let g:vim_test_plus = '+'
751+
let g:vim_test_star = '*'
752+
clipreset
753+
754+
" plus register should be disabled on windows or macos
755+
call assert_equal(0, has('clipboard_plus_avail'))
756+
call assert_equal(1, has('clipboard_star_avail'))
757+
else
758+
let g:vim_test_plus = '+'
759+
let g:vim_test_star = '*'
760+
clipreset
761+
762+
call assert_equal(1, has('clipboard_plus_avail'))
763+
call assert_equal(1, has('clipboard_star_avail'))
764+
765+
let g:vim_test_plus = ""
766+
clipreset
767+
768+
call assert_equal(0, has('clipboard_plus_avail'))
769+
endif
770+
771+
set clipmethod&
772+
endfunc
773+
730774
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
1863,
737739
/**/
738740
1862,
739741
/**/

0 commit comments

Comments
 (0)