mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
vim-patch:8.1.2348: :const cannot be followed by "| endif"
Problem: :const cannot be followed by "| endif".
Solution: Check following command for :const. (closes vim/vim#5269)
Also fix completion after :const.
8f76e6b12b
This commit is contained in:
@@ -2872,7 +2872,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx)
|
|||||||
int c;
|
int c;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
if (cmdidx == CMD_let) {
|
if (cmdidx == CMD_let || cmdidx == CMD_const) {
|
||||||
xp->xp_context = EXPAND_USER_VARS;
|
xp->xp_context = EXPAND_USER_VARS;
|
||||||
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL) {
|
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL) {
|
||||||
/* ":let var1 var2 ...": find last space. */
|
/* ":let var1 var2 ...": find last space. */
|
||||||
|
@@ -2126,6 +2126,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
|||||||
case CMD_browse:
|
case CMD_browse:
|
||||||
case CMD_call:
|
case CMD_call:
|
||||||
case CMD_confirm:
|
case CMD_confirm:
|
||||||
|
case CMD_const:
|
||||||
case CMD_delfunction:
|
case CMD_delfunction:
|
||||||
case CMD_djump:
|
case CMD_djump:
|
||||||
case CMD_dlist:
|
case CMD_dlist:
|
||||||
@@ -3437,6 +3438,7 @@ const char * set_one_cmd_context(
|
|||||||
case CMD_syntax:
|
case CMD_syntax:
|
||||||
set_context_in_syntax_cmd(xp, arg);
|
set_context_in_syntax_cmd(xp, arg);
|
||||||
break;
|
break;
|
||||||
|
case CMD_const:
|
||||||
case CMD_let:
|
case CMD_let:
|
||||||
case CMD_if:
|
case CMD_if:
|
||||||
case CMD_elseif:
|
case CMD_elseif:
|
||||||
|
@@ -159,6 +159,7 @@ func Test_expr_completion()
|
|||||||
endif
|
endif
|
||||||
for cmd in [
|
for cmd in [
|
||||||
\ 'let a = ',
|
\ 'let a = ',
|
||||||
|
\ 'const a = ',
|
||||||
\ 'if',
|
\ 'if',
|
||||||
\ 'elseif',
|
\ 'elseif',
|
||||||
\ 'while',
|
\ 'while',
|
||||||
|
@@ -176,6 +176,12 @@ func Test_cannot_modify_existing_variable()
|
|||||||
call assert_fails('const [i2, f2, s2] = [1, 1.1, "vim"]', 'E995:')
|
call assert_fails('const [i2, f2, s2] = [1, 1.1, "vim"]', 'E995:')
|
||||||
endfunc
|
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()
|
func Test_const_with_index_access()
|
||||||
let l = [1, 2, 3]
|
let l = [1, 2, 3]
|
||||||
call assert_fails('const l[0] = 4', 'E996:')
|
call assert_fails('const l[0] = 4', 'E996:')
|
||||||
|
@@ -24,6 +24,10 @@ func Test_let()
|
|||||||
let out = execute('let a {0 == 1 ? "a" : "b"}')
|
let out = execute('let a {0 == 1 ? "a" : "b"}')
|
||||||
let s = "\na #1\nb #2"
|
let s = "\na #1\nb #2"
|
||||||
call assert_equal(s, out)
|
call assert_equal(s, out)
|
||||||
|
|
||||||
|
let x = 0
|
||||||
|
if 0 | let x = 1 | endif
|
||||||
|
call assert_equal(0, x)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func s:set_arg1(a) abort
|
func s:set_arg1(a) abort
|
||||||
|
Reference in New Issue
Block a user