wildignore patterns prevent file load with --remote-silent

48 views
Skip to first unread message

hebar...@googlemail.com

unread,
Jan 5, 2024, 7:42:08 AM1/5/24
to vim_dev
Specifying "wildignore" patterns in the initialization file prevent a file matched by one of the patterns to be loaded when GVim is called with the "--remote-silent" flag.

GVim: 9.1 [1-4]
OS: Windows 10

default.vim
----------------------------
set wildignore=*.a
----------------------------

Commands
----------------------------
gvim -u default.vim                 test.a   // test.a is loaded
gvim -u default.vim --remote-silent test.a   // test.a is not loaded
gvim -u default.vim --remote-silent test.c   // test.c is loaded

----------------------------

Christian Brabandt

unread,
Jan 5, 2024, 1:03:48 PM1/5/24
to vim...@googlegroups.com
Hm, this builds a :drop command, so if you test using :drop test.a you
will also get the error message "E479: No Match".

I am not sure, if the drop command should by default ignore the
wildignore setting, probably not, you could use :drop directory/* and
would still ignore all files that match the wildignore pattern.

However, when using --remote-silent one probably wants to ignore the
wildignore setting at least when only a single file is passed.

Here is a very simple patch, that saves and restores the wildignore
setting when using `--remote`. Not sure if I should commit it.

diff --git a/src/clientserver.c b/src/clientserver.c
index cfc0ab661..a7273e376 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_u *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] == '+')
{
@@ -596,9 +600,11 @@ build_drop_cmd(
vim_free(cwd);
if (cdp == NULL)
return NULL;
- ga_init2(&ga, 1, 100);
+ ga_init2(&ga, 1, 200);
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>");



Thanks,
Christian
--
I got the bill for my surgery. Now I know what those doctors were
wearing masks for.
-- James Boren

hebar...@googlemail.com

unread,
Jan 6, 2024, 7:58:08 AM1/6/24
to vim_dev
From my point of view, honoring "wildignore" doesn't make any sense if someone tries to load a specific file, i.e. use a file name that was not created by wildcard expansion.
I'd advocate merging the patch...

Christian Brabandt

unread,
Jan 8, 2024, 1:37:48 PM1/8/24
to vim...@googlegroups.com

On Sa, 06 Jan 2024, 'hebar...@googlemail.com' via vim_dev wrote:

> From my point of view, honoring "wildignore" doesn't make any sense if
> someone tries to load a specific file, i.e. use a file name that was not
> created by wildcard expansion.
> I'd advocate merging the patch...

I created https://github.com/vim/vim/pull/13835 for this. It however
needs a proper test.


Thanks,
Christian
--
Most public domain software is free, at least at first glance.
Reply all
Reply to author
Forward
0 new messages