]> granicus.if.org Git - vim/commitdiff
patch 8.1.2348: :const cannot be followed by "| endif" v8.1.2348
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Nov 2019 15:50:30 +0000 (16:50 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Nov 2019 15:50:30 +0000 (16:50 +0100)
Problem:    :const cannot be followed by "| endif".
Solution:   Check following command for :const. (closes #5269)
            Also fix completion after :const.

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

index 7381b0e9b7c838aba42a3dd4605391eebd7a400b..1a7f9f2ecd5430dadf645d3345380f016c578701 100644 (file)
@@ -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:
index ace1e013f5ebb8eb34d31270305a383856a012cc..b65f29efcaf66b3cefaa796451e552719ac9026c 100644 (file)
@@ -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)
index 385cf3b4ae279b7007b01d5e57148547ebecfe47..576a75674a4830d809b979034a65f73b9d9d2d03 100644 (file)
@@ -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:
index 3f73d3da34950d8a4cfc1c5091b0db913faf75dc..7a4979e0152e329a49b1387a558debc33a7000da 100644 (file)
@@ -184,6 +184,7 @@ func Test_expr_completion()
   endif
   for cmd in [
        \ 'let a = ',
+       \ 'const a = ',
        \ 'if',
        \ 'elseif',
        \ 'while',
index 55e4492bde9c84c61ea2d7f85d32e0eec269e4a5..8df34f4ad65316a8e652bbfd5072173152d087f2 100644 (file)
@@ -197,6 +197,12 @@ func Test_cannot_modify_existing_variable()
     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:')
index 4d9aae96f1e95656f4733e0f834dfc13068d719b..055425de2818e5439a7f1effa91ffec53f3e084d 100644 (file)
@@ -24,6 +24,10 @@ func Test_let()
   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
index 981f92fac456becd7fbd5387e36166ccbbf1c51c..70df145126bab20aa017f94e83013e019f8e61ba 100644 (file)
@@ -737,6 +737,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2348,
 /**/
     2347,
 /**/