mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
vim-patch:9.0.0869: bogus error when string used after :elseif
Problem: Bogus error when string used after :elseif.
Solution: Do not consider a double quote the start of a comment.
(closes vim/vim#11534)
28c56d5013
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -901,7 +901,8 @@ void ex_else(exarg_T *eap)
|
|||||||
bool error;
|
bool error;
|
||||||
// When skipping we ignore most errors, but a missing expression is
|
// When skipping we ignore most errors, but a missing expression is
|
||||||
// wrong, perhaps it should have been "else".
|
// wrong, perhaps it should have been "else".
|
||||||
if (skip && ends_excmd(*eap->arg)) {
|
// A double quote here is the start of a string, not a comment.
|
||||||
|
if (skip && *eap->arg != '"' && ends_excmd(*eap->arg)) {
|
||||||
semsg(_(e_invexpr2), eap->arg);
|
semsg(_(e_invexpr2), eap->arg);
|
||||||
} else {
|
} else {
|
||||||
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
|
result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
|
||||||
|
@@ -193,6 +193,16 @@ func Test_if_while()
|
|||||||
call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath)
|
call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Check double quote after skipped "elseif" does not give error E15
|
||||||
|
func Test_skipped_elseif()
|
||||||
|
if "foo" ==? "foo"
|
||||||
|
let result = "first"
|
||||||
|
elseif "foo" ==? "foo"
|
||||||
|
let result = "second"
|
||||||
|
endif
|
||||||
|
call assert_equal('first', result)
|
||||||
|
endfunc
|
||||||
|
|
||||||
"-------------------------------------------------------------------------------
|
"-------------------------------------------------------------------------------
|
||||||
" Test 4: :return {{{1
|
" Test 4: :return {{{1
|
||||||
"-------------------------------------------------------------------------------
|
"-------------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user