mirror of
https://github.com/neovim/neovim.git
synced 2026-11-02 09:49:02 -06:00
fix(pack): close confirmation buffer, not tabpage #37756
This commit is contained in:
1 parent
6cb3254c2f
commit
0f73873d4f
2 files changed
+11
-9
No files matched your search
@@ -1115,14 +1115,10 @@ local function show_confirm_buf(lines, on_finish)
|
|||||||
api.nvim_buf_set_name(bufnr, 'nvim-pack://confirm#' .. bufnr)
|
api.nvim_buf_set_name(bufnr, 'nvim-pack://confirm#' .. bufnr)
|
||||||
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||||
vim.cmd.sbuffer({ bufnr, mods = { tab = vim.fn.tabpagenr() } })
|
vim.cmd.sbuffer({ bufnr, mods = { tab = vim.fn.tabpagenr() } })
|
||||||
local tab_id = api.nvim_get_current_tabpage()
|
|
||||||
local win_id = api.nvim_get_current_win()
|
local win_id = api.nvim_get_current_win()
|
||||||
|
|
||||||
local delete_buffer = vim.schedule_wrap(function()
|
local delete_buffer = vim.schedule_wrap(function()
|
||||||
pcall(api.nvim_buf_delete, bufnr, { force = true })
|
pcall(api.nvim_buf_delete, bufnr, { force = true })
|
||||||
if api.nvim_tabpage_is_valid(tab_id) then
|
|
||||||
vim.cmd.tabclose(api.nvim_tabpage_get_number(tab_id))
|
|
||||||
end
|
|
||||||
vim.cmd.redraw()
|
vim.cmd.redraw()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -1372,25 +1372,31 @@ describe('vim.pack', function()
|
|||||||
local other_tabpage = api.nvim_get_current_tabpage()
|
local other_tabpage = api.nvim_get_current_tabpage()
|
||||||
n.exec('tabnext')
|
n.exec('tabnext')
|
||||||
n.exec('write')
|
n.exec('write')
|
||||||
eq(true, api.nvim_tabpage_is_valid(other_tabpage))
|
eq(true, api.nvim_get_current_tabpage() == other_tabpage)
|
||||||
eq(false, api.nvim_tabpage_is_valid(confirm_tabpage))
|
eq(false, api.nvim_tabpage_is_valid(confirm_tabpage))
|
||||||
|
|
||||||
-- Not confirm with `:quit`
|
-- Not confirm with `:quit`
|
||||||
n.exec('tab split other-tab-2')
|
n.exec('tab split other-tab-2')
|
||||||
local other_tabpage_2 = api.nvim_get_current_tabpage()
|
local other_tabpage_2 = api.nvim_get_current_tabpage()
|
||||||
exec_lua(function()
|
exec_lua('vim.pack.update()')
|
||||||
vim.pack.update()
|
|
||||||
end)
|
|
||||||
confirm_tabpage = api.nvim_get_current_tabpage()
|
confirm_tabpage = api.nvim_get_current_tabpage()
|
||||||
|
|
||||||
-- - Temporary split window in tabpage should not matter
|
-- - Temporary split window in tabpage should prevent from closing
|
||||||
n.exec('vsplit other-buf')
|
n.exec('vsplit other-buf')
|
||||||
n.exec('wincmd w')
|
n.exec('wincmd w')
|
||||||
|
|
||||||
n.exec('tabclose ' .. api.nvim_tabpage_get_number(other_tabpage_2))
|
n.exec('tabclose ' .. api.nvim_tabpage_get_number(other_tabpage_2))
|
||||||
eq(confirm_tabpage, api.nvim_get_current_tabpage())
|
eq(confirm_tabpage, api.nvim_get_current_tabpage())
|
||||||
n.exec('quit')
|
n.exec('quit')
|
||||||
|
eq(confirm_tabpage, api.nvim_get_current_tabpage())
|
||||||
|
n.exec('quit')
|
||||||
eq(false, api.nvim_tabpage_is_valid(confirm_tabpage))
|
eq(false, api.nvim_tabpage_is_valid(confirm_tabpage))
|
||||||
|
|
||||||
|
-- Should work even if it is the last tabpage
|
||||||
|
exec_lua('vim.pack.update()')
|
||||||
|
n.exec('tabonly')
|
||||||
|
n.exec('write')
|
||||||
|
eq('', n.eval('v:errmsg'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('has in-process LSP features', function()
|
it('has in-process LSP features', function()
|
||||||
|
|||||||
Reference in new issue
Block a user