fix(cmdwin): allow a user to switch to other buffers #41199

This commit is contained in:
Rob Pilling
2026-08-28 18:34:31 +01:00
committed by GitHub
parent e28d725e46
commit 61958f2335
42 changed files with 64 additions and 179 deletions

View File

@@ -107,26 +107,19 @@ describe('eval-API', function()
api.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' })
eq({ 'wow!' }, api.nvim_buf_get_lines(0, 0, -1, 1))
-- Turning the cmdwin buffer into a terminal buffer would be pretty weird.
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
pcall_err(api.nvim_open_term, 0, {})
)
-- Turning the cmdwin buffer into a terminal buffer also works (#41199)
api.nvim_open_term(0, {})
api.nvim_buf_delete(0, { force = true })
matches(
'E11: Invalid in command%-line window; <CR> executes, CTRL%-C quits$',
pcall_err(
exec_lua,
[[
local cmdwin_buf = vim.api.nvim_get_current_buf()
vim._with({buf = vim.api.nvim_create_buf(false, true)}, function()
vim.api.nvim_open_term(cmdwin_buf, {})
end)
]]
)
)
feed('q:')
exec_lua([[
local cmdwin_buf = vim.api.nvim_get_current_buf()
vim._with({buf = vim.api.nvim_create_buf(false, true)}, function()
vim.api.nvim_open_term(cmdwin_buf, {})
end)
]])
-- But turning a different buffer into a terminal from the cmdwin is OK.
-- And turning a different buffer into a terminal from the cmdwin is OK.
local term_buf = api.nvim_create_buf(false, true)
api.nvim_open_term(term_buf, {})
eq('terminal', api.nvim_get_option_value('buftype', { buf = term_buf }))