mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
runtime(dist/vim9): fix regressions in dist#vim9#Open
fixes: #16533 fixes: #16532 closes: #16535 Signed-off-by: Luca Saccarola <github.e41mv@aleeas.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
a5d19aa44d
commit
766801295d
25
runtime/autoload/dist/vim9.vim
vendored
25
runtime/autoload/dist/vim9.vim
vendored
@ -3,7 +3,7 @@ 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 Jan 24
|
# Last Change: 2025 Jan 29
|
||||||
|
|
||||||
export def IsSafeExecutable(filetype: string, executable: string): bool
|
export def IsSafeExecutable(filetype: string, executable: string): bool
|
||||||
if empty(exepath(executable))
|
if empty(exepath(executable))
|
||||||
@ -34,7 +34,7 @@ if has('unix')
|
|||||||
# Cygwin provides cygstart
|
# Cygwin provides cygstart
|
||||||
if executable('cygstart')
|
if executable('cygstart')
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute 'silent ! cygstart --hide' args Redir() | redraw!
|
execute $'silent ! cygstart --hide {args} {Redir()}' | redraw!
|
||||||
enddef
|
enddef
|
||||||
elseif !empty($MSYSTEM) && executable('start')
|
elseif !empty($MSYSTEM) && executable('start')
|
||||||
# MSYS2/Git Bash comes by default without cygstart; see
|
# MSYS2/Git Bash comes by default without cygstart; see
|
||||||
@ -43,31 +43,32 @@ if has('unix')
|
|||||||
# Adding "" //b` sets void title, hides cmd window and blocks path conversion
|
# Adding "" //b` sets void title, hides cmd window and blocks path conversion
|
||||||
# of /b to \b\ " by MSYS2; see https://www.msys2.org/docs/filesystem-paths/
|
# of /b to \b\ " by MSYS2; see https://www.msys2.org/docs/filesystem-paths/
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute 'silent !start "" //b' args Redir() | redraw!
|
execute $'silent !start "" //b {args} {Redir()}' | redraw!
|
||||||
enddef
|
enddef
|
||||||
else
|
else
|
||||||
# imitate /usr/bin/start script for other environments and hope for the best
|
# imitate /usr/bin/start script for other environments and hope for the best
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute 'silent !cmd //c start "" //b' args Redir() | redraw!
|
execute $'silent !cmd /c start "" /b {args} {Redir()}' | redraw!
|
||||||
enddef
|
enddef
|
||||||
endif
|
endif
|
||||||
elseif exists('$WSL_DISTRO_NAME') # use cmd.exe to start GUI apps in WSL
|
elseif exists('$WSL_DISTRO_NAME') # use cmd.exe to start GUI apps in WSL
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute 'silent !' ..
|
const command = (args =~? '\v<\f+\.(exe|com|bat|cmd)>')
|
||||||
((args =~? '\v<\f+\.(exe|com|bat|cmd)>') ?
|
? $'cmd.exe /c start /b {args} {Redir()}'
|
||||||
$'cmd.exe /c start /b {args} {Redir()}' :
|
: $'nohup {args} {Redir()} &'
|
||||||
$'nohup {args} {Redir()} &')
|
execute $'silent ! {command}' | redraw!
|
||||||
| redraw!
|
|
||||||
enddef
|
enddef
|
||||||
else
|
else
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute ':silent ! nohup' args Redir() (has('gui_running') ? '' : '&') | redraw!
|
const fork = has('gui_running') ? '' : '&'
|
||||||
|
execute $':silent ! nohup {args} {Redir()} {fork}' | redraw!
|
||||||
enddef
|
enddef
|
||||||
endif
|
endif
|
||||||
elseif has('win32')
|
elseif has('win32')
|
||||||
export def Launch(args: string)
|
export def Launch(args: string)
|
||||||
execute 'silent !' .. (&shell =~? '\<cmd\.exe\>' ? '' : 'cmd.exe /c')
|
const shell = (&shell =~? '\<cmd\.exe\>') ? '' : 'cmd.exe /c'
|
||||||
'start "" /b' args Redir() | redraw!
|
const quotes = empty(shell) ? '' : '""'
|
||||||
|
execute $'silent ! {shell} start {quotes} /b {args} {Redir()}' | redraw!
|
||||||
enddef
|
enddef
|
||||||
else
|
else
|
||||||
export def Launch(dummy: string)
|
export def Launch(dummy: string)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*eval.txt* For Vim version 9.1. Last change: 2025 Jan 25
|
*eval.txt* For Vim version 9.1. Last change: 2025 Jan 29
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -4908,13 +4908,25 @@ executable. It takes the following arguments:
|
|||||||
executable string
|
executable string
|
||||||
|
|
||||||
*dist#vim9#Open()* *:Open*
|
*dist#vim9#Open()* *:Open*
|
||||||
*g:Openprg*
|
*g:Openprg* *gx*
|
||||||
dist#vim9#Open(file: string) ~
|
dist#vim9#Open(file: string) ~
|
||||||
|
|
||||||
Opens `path` with the system default handler (macOS `open`, Windows
|
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.
|
||||||
|
|
||||||
|
This function is by default called using the gx mapping. In visual mode
|
||||||
|
tries to open the visually selected text.
|
||||||
|
|
||||||
|
Associated setting variables:
|
||||||
|
`g:gx_word`: control how gx picks up the text under the cursor. Uses
|
||||||
|
`g:netrw_gx` as a fallback for backward compatibility.
|
||||||
|
(default: `<cfile>`)
|
||||||
|
|
||||||
|
`g:nogx`: disables the gx mapping. Uses `g:netrw_nogx` as a fallback for
|
||||||
|
backward compatibility. (default: `unset`)
|
||||||
|
|
||||||
|
|
||||||
NOTE: Escaping of the path is automatically applied.
|
NOTE: Escaping of the path is automatically applied.
|
||||||
|
|
||||||
Usage: >vim
|
Usage: >vim
|
||||||
|
@ -8053,6 +8053,7 @@ gvimrc gui.txt /*gvimrc*
|
|||||||
gw change.txt /*gw*
|
gw change.txt /*gw*
|
||||||
gwgw change.txt /*gwgw*
|
gwgw change.txt /*gwgw*
|
||||||
gww change.txt /*gww*
|
gww change.txt /*gww*
|
||||||
|
gx eval.txt /*gx*
|
||||||
gzip pi_gzip.txt /*gzip*
|
gzip pi_gzip.txt /*gzip*
|
||||||
gzip-autocmd pi_gzip.txt /*gzip-autocmd*
|
gzip-autocmd pi_gzip.txt /*gzip-autocmd*
|
||||||
gzip-example autocmd.txt /*gzip-example*
|
gzip-example autocmd.txt /*gzip-example*
|
||||||
|
@ -12,9 +12,18 @@ command -complete=file -nargs=1 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
|
||||||
|
def GetWordUnderCursor(): string
|
||||||
|
const url = matchstr(expand("<cWORD>"), '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}\ze[^A-Za-z0-9/]*$')
|
||||||
|
if !empty(url)
|
||||||
|
return url
|
||||||
|
endif
|
||||||
|
|
||||||
|
const user_var = get(g:, 'gx_word', get(g:, 'netrw_gx', '<cfile>')
|
||||||
|
return expand(user_var)
|
||||||
|
enddef
|
||||||
|
|
||||||
if maparg('gx', 'n') == ""
|
if maparg('gx', 'n') == ""
|
||||||
const file = get(g:, 'netrw_gx', '<cfile>')
|
nnoremap <unique> gx <scriptcmd>vim9.Open(GetWordUnderCursor())<CR>
|
||||||
nnoremap <unique> gx <scriptcmd>vim9.Open(expand(file))<CR>
|
|
||||||
endif
|
endif
|
||||||
if maparg('gx', 'x') == ""
|
if maparg('gx', 'x') == ""
|
||||||
xnoremap <unique> gx <scriptcmd>vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join())<CR>
|
xnoremap <unique> gx <scriptcmd>vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join())<CR>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user