Patch 8.1.2348
Problem: :const cannot be followed by "| endif".
Solution: Check following command for :const. (closes #5269)
Also fix completion after :const.
Files: src/testdir/test_let.vim, src/testdir/test_const.vim,
src/ex_docmd.c, src/cmdexpand.c, src/eval.c,
src/testdir/test_cmdline.vim
*** ../vim-8.1.2347/src/testdir/test_let.vim 2019-11-06 15:21:56.720396416 +0100
--- src/testdir/test_let.vim 2019-11-26 16:18:48.047171779 +0100
***************
*** 24,29 ****
--- 24,33 ----
let out = execute('let a {0 == 1 ? "a" : "b"}')
let s = "\na #1\nb #2"
call assert_equal(s, out)
+
+ let x = 0
+ if 0 | let x = 1 | endif
+ call assert_equal(0, x)
endfunc
func s:set_arg1(a) abort
*** ../vim-8.1.2347/src/testdir/test_const.vim 2019-09-01 14:45:23.757964939 +0200
--- src/testdir/test_const.vim 2019-11-26 16:23:08.917844874 +0100
***************
*** 197,202 ****
--- 197,208 ----
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:')
*** ../vim-8.1.2347/src/ex_docmd.c 2019-10-20 22:27:06.373331908 +0200
--- src/ex_docmd.c 2019-11-26 16:36:18.763979617 +0100
***************
*** 2359,2364 ****
--- 2359,2365 ----
case CMD_browse:
case CMD_call:
case CMD_confirm:
+ case CMD_const:
case CMD_delfunction:
case CMD_djump:
case CMD_dlist:
*** ../vim-8.1.2347/src/cmdexpand.c 2019-10-19 21:01:01.603226724 +0200
--- src/cmdexpand.c 2019-11-26 16:38:29.871550124 +0100
***************
*** 1508,1513 ****
--- 1508,1514 ----
break;
#endif
#ifdef FEAT_EVAL
+ case CMD_const:
case CMD_let:
case CMD_if:
case CMD_elseif:
*** ../vim-8.1.2347/src/eval.c 2019-10-13 16:43:35.952359672 +0200
--- src/eval.c 2019-11-26 16:44:50.250170663 +0100
***************
*** 1521,1527 ****
int c;
char_u *p;
! if (cmdidx == CMD_let)
{
xp->xp_context = EXPAND_USER_VARS;
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL)
--- 1521,1527 ----
int c;
char_u *p;
! if (cmdidx == CMD_let || cmdidx == CMD_const)
{
xp->xp_context = EXPAND_USER_VARS;
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL)
*** ../vim-8.1.2347/src/testdir/test_cmdline.vim 2019-10-27 20:36:21.876503832 +0100
--- src/testdir/test_cmdline.vim 2019-11-26 16:43:42.786426105 +0100
***************
*** 184,189 ****
--- 184,190 ----
endif
for cmd in [
\ 'let a = ',
+ \ 'const a = ',
\ 'if',
\ 'elseif',
\ 'while',
*** ../vim-8.1.2347/src/version.c 2019-11-26 14:47:56.996401931 +0100
--- src/version.c 2019-11-26 16:38:58.647452043 +0100
***************
*** 739,740 ****
--- 739,742 ----
{ /* Add new patch number below this line */
+ /**/
+ 2348,
/**/
--
I'm writing a book. I've got the page numbers done.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///