mirror of
https://github.com/vim/vim.git
synced 2025-10-04 05:25:06 -04:00
patch 8.1.0515: reloading a script gives errors for existing functions
Problem: Reloading a script gives errors for existing functions. Solution: Allow redefining a function once when reloading a script.
This commit is contained in:
@@ -1138,3 +1138,30 @@ func Test_func_range_with_edit()
|
||||
call delete('Xfuncrange2')
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_func_exists_on_reload()
|
||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
|
||||
call assert_equal(0, exists('*ExistingFunction'))
|
||||
source Xfuncexists
|
||||
call assert_equal(1, exists('*ExistingFunction'))
|
||||
" Redefining a function when reloading a script is OK.
|
||||
source Xfuncexists
|
||||
call assert_equal(1, exists('*ExistingFunction'))
|
||||
|
||||
" But redefining in another script is not OK.
|
||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
|
||||
call assert_fails('source Xfuncexists2', 'E122:')
|
||||
|
||||
delfunc ExistingFunction
|
||||
call assert_equal(0, exists('*ExistingFunction'))
|
||||
call writefile([
|
||||
\ 'func ExistingFunction()', 'echo "yes"', 'endfunc',
|
||||
\ 'func ExistingFunction()', 'echo "no"', 'endfunc',
|
||||
\ ], 'Xfuncexists')
|
||||
call assert_fails('source Xfuncexists', 'E122:')
|
||||
call assert_equal(1, exists('*ExistingFunction'))
|
||||
|
||||
call delete('Xfuncexists2')
|
||||
call delete('Xfuncexists')
|
||||
delfunc ExistingFunction
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user