mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0176
Problem: Using :change in between :function and :endfunction fails.
Solution: Recognize :change inside a function. (ichizok, closes vim/vim#1374)
70bcd7336f
This commit is contained in:
parent
d707b2a171
commit
5f8411b7bf
@ -19872,9 +19872,15 @@ void ex_function(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for ":append" or ":insert". */
|
// Check for ":append", ":change", ":insert".
|
||||||
p = skip_range(p, NULL);
|
p = skip_range(p, NULL);
|
||||||
if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|
if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|
||||||
|
|| (p[0] == 'c'
|
||||||
|
&& (!ASCII_ISALPHA(p[1])
|
||||||
|
|| (p[1] == 'h' && (!ASCII_ISALPHA(p[2])
|
||||||
|
|| (p[2] == 'a'
|
||||||
|
&& (STRNCMP(&p[3], "nge", 3) != 0
|
||||||
|
|| !ASCII_ISALPHA(p[6])))))))
|
||||||
|| (p[0] == 'i'
|
|| (p[0] == 'i'
|
||||||
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
|
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
|
||||||
&& (!ASCII_ISALPHA(p[2])
|
&& (!ASCII_ISALPHA(p[2])
|
||||||
|
@ -1064,6 +1064,77 @@ func Test_echo_and_string()
|
|||||||
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
"-------------------------------------------------------------------------------
|
||||||
|
" Test 95: lines of :append, :change, :insert {{{1
|
||||||
|
"-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function! DefineFunction(name, body)
|
||||||
|
let func = join(['function! ' . a:name . '()'] + a:body + ['endfunction'], "\n")
|
||||||
|
exec func
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
func Test_script_lines()
|
||||||
|
" :append
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Append', [
|
||||||
|
\ 'append',
|
||||||
|
\ 'py <<EOS',
|
||||||
|
\ '.',
|
||||||
|
\ ])
|
||||||
|
catch
|
||||||
|
call assert_report("Can't define function")
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Append', [
|
||||||
|
\ 'append',
|
||||||
|
\ 'abc',
|
||||||
|
\ ])
|
||||||
|
call assert_report("Shouldn't be able to define function")
|
||||||
|
catch
|
||||||
|
call assert_exception('Vim(function):E126: Missing :endfunction')
|
||||||
|
endtry
|
||||||
|
|
||||||
|
" :change
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Change', [
|
||||||
|
\ 'change',
|
||||||
|
\ 'py <<EOS',
|
||||||
|
\ '.',
|
||||||
|
\ ])
|
||||||
|
catch
|
||||||
|
call assert_report("Can't define function")
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Change', [
|
||||||
|
\ 'change',
|
||||||
|
\ 'abc',
|
||||||
|
\ ])
|
||||||
|
call assert_report("Shouldn't be able to define function")
|
||||||
|
catch
|
||||||
|
call assert_exception('Vim(function):E126: Missing :endfunction')
|
||||||
|
endtry
|
||||||
|
|
||||||
|
" :insert
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Insert', [
|
||||||
|
\ 'insert',
|
||||||
|
\ 'py <<EOS',
|
||||||
|
\ '.',
|
||||||
|
\ ])
|
||||||
|
catch
|
||||||
|
call assert_report("Can't define function")
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
call DefineFunction('T_Insert', [
|
||||||
|
\ 'insert',
|
||||||
|
\ 'abc',
|
||||||
|
\ ])
|
||||||
|
call assert_report("Shouldn't be able to define function")
|
||||||
|
catch
|
||||||
|
call assert_exception('Vim(function):E126: Missing :endfunction')
|
||||||
|
endtry
|
||||||
|
endfunc
|
||||||
|
|
||||||
"-------------------------------------------------------------------------------
|
"-------------------------------------------------------------------------------
|
||||||
" Modelines {{{1
|
" Modelines {{{1
|
||||||
" vim: ts=8 sw=4 tw=80 fdm=marker
|
" vim: ts=8 sw=4 tw=80 fdm=marker
|
||||||
|
Loading…
Reference in New Issue
Block a user