From 7c6a9c55890f77fc7b571de649c232d70db3a01a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Feb 2025 14:00:30 +0800 Subject: vim-patch:8.2.4607: sourcing buffer lines may lead to errors for conflicts Problem: Sourcing buffer lines may lead to errors for conflicts. Solution: Add the ++clear argument. (Yegappan Lakshmanan, closes vim/vim#9991) https://github.com/vim/vim/commit/35dc17634dd6da5b90bd1b0160c4ed9e394f4b87 Documentation changes only. Vim9script is N/A. Cherry-pick another documentation change for :source from latest Vim. Co-authored-by: Yegappan Lakshmanan --- test/old/testdir/test_source.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_source.vim b/test/old/testdir/test_source.vim index 6a41a54067..026a4bb5ee 100644 --- a/test/old/testdir/test_source.vim +++ b/test/old/testdir/test_source.vim @@ -607,6 +607,34 @@ func Test_source_buffer_vim9() source call assert_equal('red', g:Color) + " test for ++clear argument to clear all the functions/variables + %d _ + let lines =<< trim END + g:ScriptVarFound = exists("color") + g:MyFuncFound = exists('*Myfunc') + if g:MyFuncFound + finish + endif + var color = 'blue' + def Myfunc() + enddef + END + call setline(1, lines) + vim9cmd source + call assert_false(g:MyFuncFound) + call assert_false(g:ScriptVarFound) + vim9cmd source + call assert_true(g:MyFuncFound) + call assert_true(g:ScriptVarFound) + vim9cmd source ++clear + call assert_false(g:MyFuncFound) + call assert_false(g:ScriptVarFound) + vim9cmd source ++clear + call assert_false(g:MyFuncFound) + call assert_false(g:ScriptVarFound) + call assert_fails('vim9cmd source ++clearx', 'E475:') + call assert_fails('vim9cmd source ++abcde', 'E484:') + %bw! endfunc -- cgit