]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1986: clipboard provider does not work when redirecting messages v9.1.1986
authorFoxe Chen <chen.foxe@gmail.com>
Tue, 16 Dec 2025 19:02:20 +0000 (20:02 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 16 Dec 2025 19:02:20 +0000 (20:02 +0100)
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>
src/ex_docmd.c
src/testdir/test_eval_stuff.vim
src/version.c

index bc3c91252b4ff64d28e2e1e5001740b473c9593f..ca9e519350e2388559050acbf8a0bcf6e4a376af 100644 (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 == '+'
index eb0eaca5327104d45517551e2c5a9ec9bf154db5..c1a27abba5b3ce81f472a38c5de2574a83963732 100644 (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
index 27c364c1b7b0dbea5898452eb6a0b32267741b32..1343253f36aa327fd0fc5d2f93996c743f19285a 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1986,
 /**/
     1985,
 /**/