commit 04f476733ca4511ec642252322cc75b8032c418a
parent b756a6165a06a1bca018a30dfa6b6394dc5f1208
Author: Shadman <shadmansaleh3@gmail.com>
Date: Fri, 19 Sep 2025 17:14:49 +0600
test: fix prompt_buffer_spec flakiness (#35838)
Remove incorrect use of source_script().
Diffstat:
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua
@@ -610,7 +610,15 @@ describe('prompt buffer', function()
end)
it("sets the ': mark", function()
- source_script()
+ api.nvim_set_option_value('buftype', 'prompt', { buf = 0 })
+ exec_lua(function()
+ local buf = vim.api.nvim_get_current_buf()
+ vim.fn.prompt_setcallback(buf, function(str)
+ local last_line = vim.api.nvim_buf_line_count(buf)
+ vim.api.nvim_buf_set_lines(buf, last_line - 1, last_line - 1, true, vim.split(str, '\n'))
+ end)
+ end)
+
feed('asdf')
eq({ 1, 1 }, api.nvim_buf_get_mark(0, ':'))
feed('<cr>')
@@ -620,12 +628,13 @@ describe('prompt buffer', function()
eq({ 11, 1 }, api.nvim_buf_get_mark(0, ':'))
-- ': mark is only available in prompt buffer.
- source('set buftype=')
+ api.nvim_set_option_value('buftype', '', { buf = 0 })
eq("Invalid mark name: ':'", t.pcall_err(api.nvim_buf_get_mark, 0, ':'))
-- mark can be moved
- source('set buftype=prompt')
- eq({ 11, 1 }, api.nvim_buf_get_mark(0, ':'))
+ api.nvim_set_option_value('buftype', 'prompt', { buf = 0 })
+ local last_line = api.nvim_buf_line_count(0)
+ eq({ last_line, 1 }, api.nvim_buf_get_mark(0, ':'))
eq(true, api.nvim_buf_set_mark(0, ':', 1, 1, {}))
eq({ 1, 1 }, api.nvim_buf_get_mark(0, ':'))
end)