diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-13 07:24:44 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-13 07:30:05 +0800 |
commit | b25197258086faa94ddfaa2a74e1d0eb3695d9b3 (patch) | |
tree | 8da04d6c08300f6b09d944378cd15814af61d533 /src | |
parent | bc1dbebe1f18df719b9e357f4d8b9bea3a3581b8 (diff) | |
download | rneovim-b25197258086faa94ddfaa2a74e1d0eb3695d9b3.tar.gz rneovim-b25197258086faa94ddfaa2a74e1d0eb3695d9b3.tar.bz2 rneovim-b25197258086faa94ddfaa2a74e1d0eb3695d9b3.zip |
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)
https://github.com/vim/vim/commit/28c56d501352bd98472d23667bade683877cadcc
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_eval.c | 3 | ||||
-rw-r--r-- | src/nvim/testdir/test_vimscript.vim | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 7ffd7bad7f..bde2f3c801 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -901,7 +901,8 @@ void ex_else(exarg_T *eap) bool error; // When skipping we ignore most errors, but a missing expression is // 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); } else { result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index 0fce52f88c..c93ba9dcfc 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -193,6 +193,16 @@ func Test_if_while() call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath) 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 "------------------------------------------------------------------------------- |