From: Foxe Chen Date: Tue, 16 Dec 2025 19:02:20 +0000 (+0100) Subject: patch 9.1.1986: clipboard provider does not work when redirecting messages X-Git-Tag: v9.1.1986^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beeea8a1ce91196eb2ca073a3942089119e06600;p=thirdparty%2Fvim.git patch 9.1.1986: clipboard provider does not work when redirecting messages Problem: clipboard provider does not work when redirecting messages (BenYip, after v9.1.1972) Solution: Adjust ifdefs in ex_redir() fixes: #18937 closes: #18939 Signed-off-by: Foxe Chen Signed-off-by: Christian Brabandt --- diff --git a/src/ex_docmd.c b/src/ex_docmd.c index bc3c91252b..ca9e519350 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8856,6 +8856,10 @@ ex_redir(exarg_T *eap) close_redir(); ++arg; if (ASCII_ISALPHA(*arg) +# ifdef HAVE_CLIPMETHOD + || (clipmethod == CLIPMETHOD_PROVIDER + && (*arg == '*' || *arg == '+')) +# endif # ifdef FEAT_CLIPBOARD || *arg == '*' || *arg == '+' diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index eb0eaca532..c1a27abba5 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -783,6 +783,8 @@ func s:Copy(reg, type, lines) endfunc func Test_clipboard_provider_available() + CheckFeature clipboard_provider + let g:vim_cp_available = v:true let v:clipproviders["test"] = { @@ -810,6 +812,8 @@ func Test_clipboard_provider_available() endfunc func Test_clipboard_provider_paste() + CheckFeature clipboard_provider + let v:clipproviders["test"] = { \ "paste": { \ '+': function("s:Paste"), @@ -860,6 +864,8 @@ func Test_clipboard_provider_paste() endfunc func Test_clipboard_provider_copy() + CheckFeature clipboard_provider + let v:clipproviders["test"] = { \ "copy": { \ '+': function("s:Copy"), @@ -928,6 +934,7 @@ endfunc " clipmethod is set to a provider. If not, then the plus register points to the " star register like normal. func Test_clipboard_provider_no_unamedplus() + CheckFeature clipboard_provider CheckNotFeature unnamedplus CheckFeature clipboard_working @@ -956,6 +963,7 @@ endfunc " Same as Test_clipboard_provider_registers() but do it when +clipboard isnt " enabled. func Test_clipboard_provider_no_clipboard() + CheckFeature clipboard_provider CheckNotFeature clipboard let v:clipproviders["test"] = { @@ -984,6 +992,7 @@ endfunc " Test if clipboard provider feature doesn't break existing clipboard " functionality. func Test_clipboard_provider_sys_clipboard() + CheckFeature clipboard_provider CheckFeature clipboard_working let v:clipproviders["test"] = { @@ -1036,6 +1045,8 @@ endfunc " Test if the provider callback are only called once per register on operations " that may try calling them multiple times. func Test_clipboard_provider_accessed_once() + CheckFeature clipboard_provider + let v:clipproviders["test"] = { \ "paste": { \ '+': function("s:Paste"), @@ -1095,6 +1106,8 @@ endfunc " Test if the copying does not call the paste callback, and pasting does not all " the copy callback. func Test_clipboard_provider_copy_paste_independent() + CheckFeature clipboard_provider + let v:clipproviders["test"] = { \ "paste": { \ '+': function("s:Paste"), @@ -1152,4 +1165,33 @@ func Test_clipboard_provider_copy_paste_independent() set clipmethod& endfunc +" Test if clipboard provider feature works under :redir and execute() +func Test_clipboard_provider_redir_execute() + CheckFeature clipboard_provider + + let v:clipproviders["test"] = { + \ "copy": { + \ '+': function("s:Copy"), + \ '*': function("s:Copy") + \ } + \ } + set clipmethod=test + + redir @+ + echom "testing" + redir END + + call assert_equal("+",g:vim_copy.reg) + call assert_equal(["", "testing"], g:vim_copy.lines) + call assert_equal("v", g:vim_copy.type) + + let @+ = execute("echom 'hello world'") + + call assert_equal("+",g:vim_copy.reg) + call assert_equal(["", "hello world"], g:vim_copy.lines) + call assert_equal("v", g:vim_copy.type) + + set clipmethod& +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 27c364c1b7..1343253f36 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 */ +/**/ + 1986, /**/ 1985, /**/