0
0
mirror of https://github.com/vim/vim.git synced 2025-10-20 08:14:18 -04:00

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 <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2025-10-16 19:11:37 +00:00
committed by Christian Brabandt
parent 18d57a1b4c
commit f22cedd75f
6 changed files with 69 additions and 3 deletions

View 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;

View 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
}
}

View File

@@ -727,4 +727,48 @@ func Test_eval_string_in_special_key()
silent! echo 0{1-$"\<S--{>n|%
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

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1863,
/**/
1862,
/**/