diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-08-20 07:54:14 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-23 17:47:46 +0800 |
| commit | ffa1335047047ac00280ac742bcc6dfcc7fa3589 (patch) | |
| tree | b71be77bcee6dfb6e3f96f154c2e8a77cdf4170d /src/nvim/testdir | |
| parent | 42e9fe7d958e0ba025034c330d8e29293d828b60 (diff) | |
| download | rneovim-ffa1335047047ac00280ac742bcc6dfcc7fa3589.tar.gz rneovim-ffa1335047047ac00280ac742bcc6dfcc7fa3589.tar.bz2 rneovim-ffa1335047047ac00280ac742bcc6dfcc7fa3589.zip | |
vim-patch:8.2.4726: cannot use expand() to get the script name
Problem: Cannot use expand() to get the script name.
Solution: Support expand('<script>'). (closes vim/vim#10121)
https://github.com/vim/vim/commit/6013d0045dec7ca7c0068fbe186c42d754a7368b
Use `.sn_name` instead of `->sn_name` as v8.2.0154 hasn't been ported.
Cherry-pick builtin.txt expand() doc from latest Vim.
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_expand.vim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_expand.vim b/src/nvim/testdir/test_expand.vim index ce414e4b11..4b9140ef50 100644 --- a/src/nvim/testdir/test_expand.vim +++ b/src/nvim/testdir/test_expand.vim @@ -147,4 +147,54 @@ func Test_expandcmd_shell_nonomatch() call assert_equal('$*', expandcmd('$*')) endfunc +func Test_expand_script_source() + let lines0 =<< trim [SCRIPT] + let g:script_level[0] = expand('<script>:t') + so Xscript1 + func F0() + let g:func_level[0] = expand('<script>:t') + endfunc + [SCRIPT] + + let lines1 =<< trim [SCRIPT] + let g:script_level[1] = expand('<script>:t') + so Xscript2 + func F1() + let g:func_level[1] = expand('<script>:t') + endfunc + [SCRIPT] + + let lines2 =<< trim [SCRIPT] + let g:script_level[2] = expand('<script>:t') + func F2() + let g:func_level[2] = expand('<script>:t') + endfunc + [SCRIPT] + + call writefile(lines0, 'Xscript0') + call writefile(lines1, 'Xscript1') + call writefile(lines2, 'Xscript2') + + " Check the expansion of <script> at script and function level. + let g:script_level = ['', '', ''] + let g:func_level = ['', '', ''] + + so Xscript0 + call F0() + call F1() + call F2() + + call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:script_level) + call assert_equal(['Xscript0', 'Xscript1', 'Xscript2'], g:func_level) + + unlet g:script_level g:func_level + delfunc F0 + delfunc F1 + delfunc F2 + + call delete('Xscript0') + call delete('Xscript1') + call delete('Xscript2') +endfunc + " vim: shiftwidth=2 sts=2 expandtab |