mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
patch 8.2.0427: it is not possible to check for a typo in a feature name
Problem: It is not possible to check for a typo in a feature name. Solution: Add an extra argument to has().
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
*eval.txt* For Vim version 8.2. Last change: 2020 Mar 16
|
||||
*eval.txt* For Vim version 8.2. Last change: 2020 Mar 22
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -2515,7 +2515,7 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
||||
glob2regpat({expr}) String convert a glob pat into a search pat
|
||||
globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
||||
String do glob({expr}) for all dirs in {path}
|
||||
has({feature}) Number |TRUE| if feature {feature} supported
|
||||
has({feature} [, {check}]) Number |TRUE| if feature {feature} supported
|
||||
has_key({dict}, {key}) Number |TRUE| if {dict} has entry {key}
|
||||
haslocaldir([{winnr} [, {tabnr}]])
|
||||
Number |TRUE| if the window executed |:lcd|
|
||||
@@ -4358,8 +4358,8 @@ feedkeys({string} [, {mode}]) *feedkeys()*
|
||||
'L' Lowlevel input. Only works for Unix or when using the
|
||||
GUI. Keys are used as if they were coming from the
|
||||
terminal. Other flags are not used. *E980*
|
||||
When a CTRL-C interrupts it sets the internal
|
||||
"got_int" flag.
|
||||
When a CTRL-C interrupts and 't' is included it sets
|
||||
the internal "got_int" flag.
|
||||
'i' Insert the string instead of appending (see above).
|
||||
'x' Execute commands until typeahead is empty. This is
|
||||
similar to using ":normal!". You can call feedkeys()
|
||||
@@ -5828,10 +5828,20 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
|
||||
GetExpr()->globpath(&rtp)
|
||||
<
|
||||
*has()*
|
||||
has({feature}) The result is a Number, which is 1 if the feature {feature} is
|
||||
supported, zero otherwise. The {feature} argument is a
|
||||
string. See |feature-list| below.
|
||||
has({feature} [, {check}])
|
||||
When {check} is omitted or is zero: The result is a Number,
|
||||
which is 1 if the feature {feature} is supported, zero
|
||||
otherwise. The {feature} argument is a string, case is
|
||||
ignored. See |feature-list| below.
|
||||
|
||||
When {check} is present and not zero: The result is a Number,
|
||||
which is 1 if the feature {feature} could ever be supported,
|
||||
zero otherwise. This is useful to check for a typo in
|
||||
{feature}. Keep in mind that an older Vim version will not
|
||||
know about a feature added later.
|
||||
|
||||
Also see |exists()|.
|
||||
|
||||
Note that to skip code that has a syntax error when the
|
||||
feature is not available, Vim may skip the rest of the line
|
||||
and miss a following `endif`. Therfore put the `endif` on a
|
||||
|
1727
src/evalfunc.c
1727
src/evalfunc.c
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,9 @@ command -nargs=1 MissingFeature throw 'Skipped: ' .. <args> .. ' feature missing
|
||||
" Command to check for the presence of a feature.
|
||||
command -nargs=1 CheckFeature call CheckFeature(<f-args>)
|
||||
func CheckFeature(name)
|
||||
if !has(a:name, 1)
|
||||
throw 'Checking for non-existent feature ' .. a:name
|
||||
endif
|
||||
if !has(a:name)
|
||||
MissingFeature a:name
|
||||
endif
|
||||
|
@@ -20,6 +20,14 @@ func Test_00_bufexists()
|
||||
call assert_equal(0, bufexists('Xfoo'))
|
||||
endfunc
|
||||
|
||||
func Test_has()
|
||||
call assert_equal(1, has('eval'))
|
||||
call assert_equal(1, has('eval', 1))
|
||||
|
||||
call assert_equal(0, has('nonexistent'))
|
||||
call assert_equal(0, has('nonexistent', 1))
|
||||
endfunc
|
||||
|
||||
func Test_empty()
|
||||
call assert_equal(1, empty(''))
|
||||
call assert_equal(0, empty('a'))
|
||||
@@ -1586,7 +1594,7 @@ func Test_confirm()
|
||||
call assert_equal(2, a)
|
||||
|
||||
" confirm() should return 0 when pressing CTRL-C.
|
||||
call feedkeys("\<C-c>", 'L')
|
||||
call feedkeys("\<C-C>", 'L')
|
||||
let a = confirm('Are you sure?', "&Yes\n&No")
|
||||
call assert_equal(0, a)
|
||||
|
||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
427,
|
||||
/**/
|
||||
426,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user