Mercurial > vim
changeset 18713:baf890fa1621 v8.1.2348
patch 8.1.2348: :const cannot be followed by "| endif"
Commit: https://github.com/vim/vim/commit/8f76e6b12b958f2779444a92234bbaf3f49eeb99
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 26 16:50:30 2019 +0100
patch 8.1.2348: :const cannot be followed by "| endif"
Problem: :const cannot be followed by "| endif".
Solution: Check following command for :const. (closes https://github.com/vim/vim/issues/5269)
Also fix completion after :const.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Nov 2019 17:00:04 +0100 |
parents | 9135f4563b16 |
children | 85d425beb6c1 |
files | src/cmdexpand.c src/eval.c src/ex_docmd.c src/testdir/test_cmdline.vim src/testdir/test_const.vim src/testdir/test_let.vim src/version.c |
diffstat | 7 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cmdexpand.c +++ b/src/cmdexpand.c @@ -1508,6 +1508,7 @@ set_one_cmd_context( break; #endif #ifdef FEAT_EVAL + case CMD_const: case CMD_let: case CMD_if: case CMD_elseif:
--- a/src/eval.c +++ b/src/eval.c @@ -1521,7 +1521,7 @@ set_context_for_expression( int c; char_u *p; - if (cmdidx == CMD_let) + if (cmdidx == CMD_let || cmdidx == CMD_const) { xp->xp_context = EXPAND_USER_VARS; if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL)
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2359,6 +2359,7 @@ do_one_cmd( case CMD_browse: case CMD_call: case CMD_confirm: + case CMD_const: case CMD_delfunction: case CMD_djump: case CMD_dlist:
--- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -184,6 +184,7 @@ func Test_expr_completion() endif for cmd in [ \ 'let a = ', + \ 'const a = ', \ 'if', \ 'elseif', \ 'while',
--- a/src/testdir/test_const.vim +++ b/src/testdir/test_const.vim @@ -197,6 +197,12 @@ func Test_cannot_modify_existing_variabl call assert_fails('const [i2, f2, s2] = [1, 1.1, "vim"]', 'E995:') endfunc +func Test_const_with_condition() + const x = 0 + if 0 | const x = 1 | endif + call assert_equal(0, x) +endfunc + func Test_const_with_index_access() let l = [1, 2, 3] call assert_fails('const l[0] = 4', 'E996:')