Skip to content

Commit b2a4c11

Browse files
authored
runtime(dist): Make dist/vim.vim work properly when lacking vim9script support (#13487)
`:return` cannot be used outside of `:function` (or `:def`) in older Vims lacking Vim9script support or in Neovim, even when evaluation is being skipped in the dead `:else` branch. Instead, use the pattern described in `:h vim9-mix`, which uses `:finish` to end script processing before it reaches the vim9script stuff. Signed-off-by: Sean Dewar <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 6709816 commit b2a4c11

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

runtime/autoload/dist/vim.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ if !exists('g:gzip_exec')
1515
let g:gzip_exec = 1
1616
endif
1717

18-
if !exists(":def")
19-
function dist#vim#IsSafeExecutable(filetype, executable)
18+
if !has('vim9script')
19+
function dist#vim#IsSafeExecutable(filetype, executable)
2020
let cwd = getcwd()
2121
return get(g:, a:filetype .. '_exec', get(g:, 'plugin_exec', 0)) &&
2222
\ (fnamemodify(exepath(a:executable), ':p:h') !=# cwd
2323
\ || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1 &&
2424
\ cwd != '.'))
25-
endfunction
26-
else
27-
def dist#vim#IsSafeExecutable(filetype: string, executable: string): bool
28-
return dist#vim9#IsSafeExecutable(filetype, executable)
29-
enddef
25+
endfunction
26+
27+
finish
3028
endif
29+
30+
def dist#vim#IsSafeExecutable(filetype: string, executable: string): bool
31+
return dist#vim9#IsSafeExecutable(filetype, executable)
32+
enddef

0 commit comments

Comments
 (0)