patch 9.1.0045: --remote-* does not ignore `wilidignore`

Commit: 
https://github.com/vim/vim/commit/cc979b49dcb2392a2c6767d3a7e05a6e07ed7201
Author: Christian Brabandt <c...@256bit.org>
Date:   Tue Jan 23 21:13:58 2024 +0100

    patch 9.1.0045: --remote-* does not ignore `wilidignore`
    
    Problem:  --remote-silent applies the wildignore option
              to each argument, which may result in "E479: No match"
              (hebaronson)
    Solution: temporarily reset 'wildignore' setting when building
              the :drop command
    
    closes: #13835
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/clientserver.c b/src/clientserver.c
index cfc0ab661..340add315 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -566,6 +566,10 @@ build_drop_cmd(
     char_u     *p;
     char_u     *cdp;
     char_u     *cwd;
+    // reset wildignore temporarily
+    const char *wig[] =
+    { "<CR><C-\><C-N>:let g:_wig=&wig|set wig=",
+      "<C-\><C-N>:let &wig=g:_wig|unlet g:_wig<CR>"};
 
     if (filec > 0 && filev[0][0] == '+')
     {
@@ -599,6 +603,8 @@ build_drop_cmd(
     ga_init2(&ga, 1, 100);
     ga_concat(&ga, (char_u *)"<C-\><C-N>:cd ");
     ga_concat(&ga, cdp);
+    // reset wildignorecase temporarily
+    ga_concat(&ga, (char_u *)wig[0]);
 
     // Call inputsave() so that a prompt for an encryption key works.
     ga_concat(&ga, (char_u *)
@@ -650,6 +656,8 @@ build_drop_cmd(
     ga_concat(&ga, cdp);
     ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>");
     vim_free(cdp);
+    // reset wildignorecase
+    ga_concat(&ga, (char_u *)wig[1]);
 
     if (sendReply)
        ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>");
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 1614cf0dc..8dd04e79e 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -248,6 +248,7 @@ NEW_TESTS = \
        test_regexp_utf8 \
        test_registers \
        test_reltime \
+       test_remote \
        test_rename \
        test_restricted \
        test_retab \
@@ -492,6 +493,7 @@ NEW_TESTS_RES = \
        test_recover.res \
        test_regex_char_classes.res \
        test_registers.res \
+       test_remote.res \
        test_rename.res \
        test_restricted.res \
        test_retab.res \
diff --git a/src/testdir/test_remote.vim b/src/testdir/test_remote.vim
new file mode 100644
index 000000000..ae931fd29
--- /dev/null
+++ b/src/testdir/test_remote.vim
@@ -0,0 +1,79 @@
+" Test for the --remote functionality
+
+source check.vim
+CheckFeature clientserver
+CheckFeature terminal
+
+source shared.vim
+source screendump.vim
+source mouse.vim
+source term_util.vim
+
+let s:remote_works = 0
+let s:skip = 'Skipped: --remote feature is not possible'
+
+" nees to be run as first test to verify, that vim --servername works
+func Verify_remote_feature_works()
+  CheckRunVimInTerminal
+  enew
+  let buf = RunVimInTerminal('--servername XVIMTEST', {'rows': 8})
+  call TermWait(buf)
+  let cmd = GetVimCommandCleanTerm() .. '--serverlist'
+  call term_sendkeys(buf, ":r! " .. cmd .. "\<CR>")
+  call TermWait(buf)
+  call term_sendkeys(buf, ":w! XVimRemoteTest.txt\<CR>")
+  call TermWait(buf)
+  call term_sendkeys(buf, ":q\<CR>")
+  call StopVimInTerminal(buf)
+  bw!
+  let result = readfile('XVimRemoteTest.txt')
+  call delete('XVimRemoteTest.txt')
+  if empty(result)
+    throw s:skip
+  endif
+  let s:remote = 1
+endfunc
+
+call Verify_remote_feature_works()
+
+if !s:remote
+  finish
+endif
+
+func Test_remote_servername()
+  CheckRunVimInTerminal
+
+  " That is the file we want the server to open,
+  " despite the wildignore setting
+  call writefile(range(1, 20), 'XTEST.txt', 'D')
+  " just a dummy file, so that the ':wq' further down is successful
+  call writefile(range(1, 20), 'Xdummy.log', 'D')
+
+  " Run Vim in a terminal and open a terminal window to run Vim in.
+  let lines =<< trim END
+    set wildignore=*.txt
+  END
+  call writefile(lines, 'XRemoteEditing.vim', 'D')
+  let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing.vim  
Xdummy.log', {'rows': 8})
+  call TermWait(buf)
+  botright new
+  " wildignore setting should be ignored and the XVIMTEST server should now
+  " open XTEST.txt, if wildignore setting is not ignored, the server
+  " will continue with the Xdummy.log file
+  let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent 
XTEST.txt', {'rows': 5, 'wait_for_ruler': 0})
+  " job should be no-longer running, so we can just close it
+  exe buf2 .. 'bw!'
+  call term_sendkeys(buf, ":sil :3,$d\<CR>")
+  call TermWait(buf)
+  call term_sendkeys(buf, ":wq!\<CR>")
+  call TermWait(buf)
+  if term_getstatus(buf) == 'running'
+    call StopVimInTerminal(buf)
+  endif
+  let buf_contents = readfile('XTEST.txt')
+  call assert_equal(2, len(buf_contents))
+  bw!
+  close
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index d6bd9acd1..925451218 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    45,
 /**/
     44,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rSNPH-009asw-Mb%40256bit.org.

Reply via email to