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 <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2025-12-16 20:02:20 +01:00
committed by Christian Brabandt
parent bbf616a9d6
commit beeea8a1ce
3 changed files with 48 additions and 0 deletions
+4
View File
@@ -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 == '+'
+42
View File
@@ -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
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1986,
/**/
1985,
/**/