diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-10-14 08:55:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-14 00:55:50 +0000 |
| commit | f28a48e38bcbbc6ba2f9544eee1119b3fcc19bfb (patch) | |
| tree | b5e855f9f1da7aeecb2f8f6d9dfad2273f816c8d /runtime | |
| parent | 544d8cd7e6289ca98e9104b55cdb963eeda51755 (diff) | |
| download | rneovim-f28a48e38bcbbc6ba2f9544eee1119b3fcc19bfb.tar.gz rneovim-f28a48e38bcbbc6ba2f9544eee1119b3fcc19bfb.tar.bz2 rneovim-f28a48e38bcbbc6ba2f9544eee1119b3fcc19bfb.zip | |
vim-patch:partial:d6f7a03: runtime(misc): Use correct terminal feature test in ftplugins (#42340)
Problem: The current test 'exists(':terminal') == 2' is valid even in
Vim builds that have the terminal not included (e.g. normal
feature builds) and thus the K key would cause an error:
"E319: Sorry, the command is not available in this version" or
"E117: Unknown function: term_start()"
Solution: Change the terminal feature test to "has('terminal')" to
properly detect Vims without the terminal feature and use
exists('*term_start') for functionality that depends on Vims
support for the term_start() feature. While at it, change the
Last Change date to the preferred style for Vim runtime files.
https://github.com/vim/vim/commit/d6f7a03f7c569d84f34259c68dabfe9b357ba0fb
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/ftplugin/ps1.vim | 3 | ||||
| -rw-r--r-- | runtime/ftplugin/sh.vim | 3 | ||||
| -rw-r--r-- | runtime/ftplugin/zsh.vim | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/runtime/ftplugin/ps1.vim b/runtime/ftplugin/ps1.vim index 9ff764a282..6e7876e2a8 100644 --- a/runtime/ftplugin/ps1.vim +++ b/runtime/ftplugin/ps1.vim @@ -7,6 +7,7 @@ " 2024 Sep 19 by Konfekt (simplify keywordprg #15696) " 2025 Jul 22 by phanium (use :hor term #17822) " 2026 Jul 10 by Vim Project (quote K argument, prevent command injection) +" 2026 Sep 01 by Vim Project (use correct terminal feature test) " Only do this when not done yet for this buffer if exists("b:did_ftplugin") | finish | endif @@ -52,7 +53,7 @@ elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe' endif if exists('s:pwsh_cmd') - if exists(':terminal') == 2 + if exists('*term_start') command! -buffer -nargs=1 GetHelp call term_start([s:pwsh_cmd, '-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'RemoteSigned', '-Command', "Get-Help -Full '" . substitute(<q-args>, "'", "''", 'g') . "'" . (executable('less') ? ' | less' : '')]) else command! -buffer -nargs=1 GetHelp echo system([s:pwsh_cmd, '-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'RemoteSigned', '-Command', "Get-Help -Full '" . substitute(<q-args>, "'", "''", 'g') . "'"]) diff --git a/runtime/ftplugin/sh.vim b/runtime/ftplugin/sh.vim index 45e6f44fcf..1652553698 100644 --- a/runtime/ftplugin/sh.vim +++ b/runtime/ftplugin/sh.vim @@ -9,6 +9,7 @@ " 2025 Mar 09 by Vim Project (set b:match_skip) " 2025 Jul 22 by phanium (use :hor term #17822) " 2026 Jul 10 by Vim Project (pass K argument as a list, prevent shell injection) +" 2026 Sep 01 by Vim Project (use correct terminal feature test) if exists("b:did_ftplugin") finish @@ -54,7 +55,7 @@ let s:is_bash = get(b:, "is_bash", get(g:, "is_bash", 0)) let s:is_kornshell = get(b:, "is_kornshell", get(g:, "is_kornshell", 0)) if s:is_bash - if exists(':terminal') == 2 + if exists('*term_start') command! -buffer -nargs=1 ShKeywordPrg call term_start(['bash', '-c', 'help "$1" 2>/dev/null || man "$1"', '--', <q-args>]) else command! -buffer -nargs=1 ShKeywordPrg echo system(['bash', '-c', 'help "$1" 2>/dev/null || MANPAGER= man "$1"', '--', <q-args>]) diff --git a/runtime/ftplugin/zsh.vim b/runtime/ftplugin/zsh.vim index 8163585939..6c529c4e19 100644 --- a/runtime/ftplugin/zsh.vim +++ b/runtime/ftplugin/zsh.vim @@ -2,7 +2,7 @@ " Language: Zsh shell script " Maintainer: Christian Brabandt <cb@256bit.org> " Previous Maintainer: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2026 Jul 23 +" Latest Revision: 2026 Sep 01 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-zsh @@ -24,7 +24,7 @@ if get(g:, 'zsh_fold_enable', 0) endif if executable('zsh') && &shell !~# '/\%(nologin\|false\)$' - if exists(':terminal') == 2 + if exists('*term_start') command! -buffer -nargs=1 ZshKeywordPrg call term_start(['zsh', '-c', 'autoload -Uz run-help; run-help "$1"', '--', <q-args>]) elseif has("patch-9.2.0250") command! -buffer -nargs=1 ZshKeywordPrg echo system(['zsh', '-c', 'autoload -Uz run-help; MANPAGER= run-help "$1" 2>/dev/null', '--', <q-args>]) |