From f28a48e38bcbbc6ba2f9544eee1119b3fcc19bfb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 14 Oct 2026 08:55:50 +0800 Subject: 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 --- runtime/ftplugin/ps1.vim | 3 ++- runtime/ftplugin/sh.vim | 3 ++- runtime/ftplugin/zsh.vim | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'runtime') 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(, "'", "''", '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(, "'", "''", '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"', '--', ]) else command! -buffer -nargs=1 ShKeywordPrg echo system(['bash', '-c', 'help "$1" 2>/dev/null || MANPAGER= man "$1"', '--', ]) 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 " Previous Maintainer: Nikolai Weibull -" 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"', '--', ]) 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', '--', ]) -- cgit