aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/repeat.txt16
-rw-r--r--test/old/testdir/test_source.vim28
2 files changed, 37 insertions, 7 deletions
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index d653a8f9fd..158ea6a4a1 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -197,13 +197,15 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
Triggers the |SourcePre| autocommand.
:[range]so[urce] Read Ex commands or Lua code from the [range] of lines
- in the current buffer. The buffer is treated as Lua
- code if 'filetype' is "lua" or its filename ends with
- ".lua". When sourcing commands or Lua code from the
- current buffer, the same script-ID |<SID>| is used
- even if the buffer is sourced multiple times. If a
- buffer is sourced more than once, then the functions
- in the buffer are redefined again.
+ in the current buffer. When [range] is omitted read
+ all lines. The buffer is treated as Lua code if its
+ 'filetype' is "lua" or its filename ends with ".lua".
+
+ When sourcing commands or Lua code from the current
+ buffer, the same script-ID |<SID>| is used even if the
+ buffer is sourced multiple times. If a buffer is
+ sourced more than once, then the functions in the
+ buffer are defined again.
*:source!*
:so[urce]! {file}
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