0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

runtime(openPlugin): fix E480 when opening URLs with wildcards on Windows

This might be a bug in Windows Vim, as when using the following command
it throws E480:
```
:com! -complete=file -nargs=1 :Echo echo <q-args>
:Echo ?
E480: No match ?
```

Work-around this by using `-nargs=*` to allow more arguments, even
though this is not completely correct.

fixes: #17029

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt 2025-04-02 19:32:03 +02:00
parent de8f8f732a
commit 9301b437bc
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 22 additions and 5 deletions

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 9.1. Last change: 2025 Mar 30 *eval.txt* For Vim version 9.1. Last change: 2025 Apr 02
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -5149,7 +5149,7 @@ executable. It takes the following arguments:
filetype string filetype string
executable string executable string
*dist#vim9#Open()* *:Open* *dist#vim9#Open()* *:Open* *:URLOpen*
*g:Openprg* *gx* *g:Openprg* *gx*
dist#vim9#Open(file: string) ~ dist#vim9#Open(file: string) ~
@ -5157,6 +5157,8 @@ Opens `path` with the system default handler (macOS `open`, Windows
`explorer.exe`, Linux `xdg-open`, …). If the variable |g:Openprg| exists the `explorer.exe`, Linux `xdg-open`, …). If the variable |g:Openprg| exists the
string specified in the variable is used instead. string specified in the variable is used instead.
The |:Open| user command uses file completion for its argument.
This function is by default called using the gx mapping. In visual mode This function is by default called using the gx mapping. In visual mode
tries to open the visually selected text. tries to open the visually selected text.
@ -5175,6 +5177,9 @@ Usage: >vim
:call dist#vim9#Open(<path>) :call dist#vim9#Open(<path>)
:Open <path> :Open <path>
< <
*package-open*
The |:Open| and |:Launch| command are provided by the included plugin
$VIMRUNTIME/plugin/openPlugin.vim
*dist#vim9#Launch()* *:Launch* *dist#vim9#Launch()* *:Launch*
dist#vim9#Launch(file: string) ~ dist#vim9#Launch(file: string) ~
@ -5182,6 +5187,8 @@ dist#vim9#Launch(file: string) ~
Launches <args> with the appropriate system programs. Intended for launching Launches <args> with the appropriate system programs. Intended for launching
GUI programs within Vim. GUI programs within Vim.
The |:Launch| user command uses shell completion for its first argument.
NOTE: escaping of <args> is left to the user NOTE: escaping of <args> is left to the user
Examples: >vim Examples: >vim

View File

@ -2188,6 +2188,7 @@ $quote eval.txt /*$quote*
:TermdebugCommand terminal.txt /*:TermdebugCommand* :TermdebugCommand terminal.txt /*:TermdebugCommand*
:Texplore pi_netrw.txt /*:Texplore* :Texplore pi_netrw.txt /*:Texplore*
:Tutor pi_tutor.txt /*:Tutor* :Tutor pi_tutor.txt /*:Tutor*
:URLOpen eval.txt /*:URLOpen*
:Until terminal.txt /*:Until* :Until terminal.txt /*:Until*
:Up terminal.txt /*:Up* :Up terminal.txt /*:Up*
:UseVimball pi_vimball.txt /*:UseVimball* :UseVimball pi_vimball.txt /*:UseVimball*
@ -9448,6 +9449,7 @@ package-hlyank usr_05.txt /*package-hlyank*
package-justify usr_25.txt /*package-justify* package-justify usr_25.txt /*package-justify*
package-matchit usr_05.txt /*package-matchit* package-matchit usr_05.txt /*package-matchit*
package-nohlsearch usr_05.txt /*package-nohlsearch* package-nohlsearch usr_05.txt /*package-nohlsearch*
package-open eval.txt /*package-open*
package-termdebug terminal.txt /*package-termdebug* package-termdebug terminal.txt /*package-termdebug*
package-translate_example repeat.txt /*package-translate_example* package-translate_example repeat.txt /*package-translate_example*
package-translation repeat.txt /*package-translation* package-translation repeat.txt /*package-translation*

View File

@ -3,12 +3,20 @@ vim9script
# Vim runtime support library # Vim runtime support library
# #
# Maintainer: The Vim Project <https://github.com/vim/vim> # Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2025 Feb 01 # Last Change: 2025 Apr 02
if exists("g:loaded_openPlugin") || &cp
finish
endif
g:loaded_openPlugin = 1
import autoload 'dist/vim9.vim' import autoload 'dist/vim9.vim'
command -complete=shellcmd -nargs=1 Launch vim9.Launch(trim(<q-args>)) command -complete=shellcmd -nargs=1 Launch vim9.Launch(trim(<q-args>))
command -complete=file -nargs=1 Open vim9.Open(trim(<q-args>))
# technically, -nargs=1 is correct, but this throws E480: No match
# when the argument contains a wildchar on Windows
command -complete=file -nargs=* Open vim9.Open(trim(<q-args>))
const no_gx = get(g:, "nogx", get(g:, "netrw_nogx", false)) const no_gx = get(g:, "nogx", get(g:, "netrw_nogx", false))
if !no_gx if !no_gx