aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-24 16:20:19 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-02-28 18:21:08 +0800
commit6750d00fe96a04ab19cfc55fb406f6b40dbf970f (patch)
tree1cce38d22bbaccd9d250db074d7c3ba236526ce2 /test/functional/api/vim_spec.lua
parenta3a9f86d4a11029542a94b00044b5a181a68c9cd (diff)
downloadrneovim-6750d00fe96a04ab19cfc55fb406f6b40dbf970f.tar.gz
rneovim-6750d00fe96a04ab19cfc55fb406f6b40dbf970f.tar.bz2
rneovim-6750d00fe96a04ab19cfc55fb406f6b40dbf970f.zip
vim-patch:8.2.4603: sourcing buffer lines is too complicated
Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) https://github.com/vim/vim/commit/85b43c6cb7d56919e245622f4e42db6d8bee4194 This commit changes the behavior of sourcing buffer lines to always have a script ID, although sourcing the same buffer always produces the same script ID. vim-patch:9.1.0372: Calling CLEAR_FIELD() on the same struct twice Problem: Calling CLEAR_FIELD() on the same struct twice. Solution: Remove the second CLEAR_FIELD(). Move the assignment of cookie.sourceing_lnum (zeertzjq). closes: vim/vim#14627 https://github.com/vim/vim/commit/f68517c1671dfedcc1555da50bc0b3de6d2842f6 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua30
1 files changed, 23 insertions, 7 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 3aa9ba49d5..b5fcd88f71 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -140,7 +140,7 @@ describe('API', function()
it(':verbose set {option}?', function()
api.nvim_exec2('set nowrap', { output = false })
eq(
- { output = 'nowrap\n\tLast set from anonymous :source' },
+ { output = 'nowrap\n\tLast set from anonymous :source line 1' },
api.nvim_exec2('verbose set wrap?', { output = true })
)
@@ -153,7 +153,7 @@ describe('API', function()
{ output = false }
)
eq(
- { output = 'nowrap\n\tLast set from anonymous :source (script id 1)' },
+ { output = 'nowrap\n\tLast set from anonymous :source (script id 1) line 2' },
api.nvim_exec2('verbose set wrap?', { output = true })
)
end)
@@ -296,16 +296,21 @@ describe('API', function()
eq('ñxx', api.nvim_get_current_line())
end)
+ it('can use :finish', function()
+ api.nvim_exec2('let g:var = 123\nfinish\nlet g:var = 456', {})
+ eq(123, api.nvim_get_var('var'))
+ end)
+
it('execution error', function()
eq(
- 'nvim_exec2(): Vim:E492: Not an editor command: bogus_command',
+ 'nvim_exec2(), line 1: Vim:E492: Not an editor command: bogus_command',
pcall_err(request, 'nvim_exec2', 'bogus_command', {})
)
eq('', api.nvim_eval('v:errmsg')) -- v:errmsg was not updated.
eq('', eval('v:exception'))
eq(
- 'nvim_exec2(): Vim(buffer):E86: Buffer 23487 does not exist',
+ 'nvim_exec2(), line 1: Vim(buffer):E86: Buffer 23487 does not exist',
pcall_err(request, 'nvim_exec2', 'buffer 23487', {})
)
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
@@ -338,17 +343,28 @@ describe('API', function()
write_file(sourcing_fname, 'call nvim_exec2("source ' .. fname .. '", {"output": v:false})\n')
api.nvim_exec2('set verbose=2', { output = false })
local traceback_output = dedent([[
- line 0: sourcing "%s"
- line 0: sourcing "%s"
+ sourcing "nvim_exec2()"
+ line 1: sourcing "nvim_exec2() called at nvim_exec2():1"
+ line 1: sourcing "%s"
+ line 1: sourcing "nvim_exec2() called at %s:1"
+ line 1: sourcing "%s"
hello
finished sourcing %s
continuing in nvim_exec2() called at %s:1
+ finished sourcing nvim_exec2() called at %s:1
+ continuing in %s
finished sourcing %s
- continuing in nvim_exec2() called at nvim_exec2():0]]):format(
+ continuing in nvim_exec2() called at nvim_exec2():1
+ finished sourcing nvim_exec2() called at nvim_exec2():1
+ continuing in nvim_exec2()
+ finished sourcing nvim_exec2()]]):format(
+ sourcing_fname,
sourcing_fname,
fname,
fname,
sourcing_fname,
+ sourcing_fname,
+ sourcing_fname,
sourcing_fname
)
eq(