mirror of
https://github.com/neovim/neovim.git
synced 2026-04-24 00:05:36 +00:00
Merge pull request #9667 from bfredl/winclose
api: add nvim_win_close() to close window by id
This commit is contained in:
@@ -286,4 +286,41 @@ describe('API/win', function()
|
||||
ok(not window('is_valid', win))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('close', function()
|
||||
it('can close current window', function()
|
||||
local oldwin = meths.get_current_win()
|
||||
command('split')
|
||||
local newwin = meths.get_current_win()
|
||||
meths.win_close(newwin,false)
|
||||
eq({oldwin}, meths.list_wins())
|
||||
end)
|
||||
|
||||
it('can close noncurrent window', function()
|
||||
local oldwin = meths.get_current_win()
|
||||
command('split')
|
||||
local newwin = meths.get_current_win()
|
||||
meths.win_close(oldwin,false)
|
||||
eq({newwin}, meths.list_wins())
|
||||
end)
|
||||
|
||||
it('handles changed buffer', function()
|
||||
local oldwin = meths.get_current_win()
|
||||
insert('text')
|
||||
command('new')
|
||||
local newwin = meths.get_current_win()
|
||||
eq({false,"Vim:E37: No write since last change (add ! to override)"},
|
||||
meth_pcall(meths.win_close, oldwin,false))
|
||||
eq({newwin,oldwin}, meths.list_wins())
|
||||
end)
|
||||
|
||||
it('handles changed buffer with force', function()
|
||||
local oldwin = meths.get_current_win()
|
||||
insert('text')
|
||||
command('new')
|
||||
local newwin = meths.get_current_win()
|
||||
meths.win_close(oldwin,true)
|
||||
eq({newwin}, meths.list_wins())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -118,6 +118,37 @@ describe('floating windows', function()
|
||||
|
|
||||
]])
|
||||
end
|
||||
|
||||
meths.win_close(win, false)
|
||||
if multigrid then
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
[2:----------------------------------------]|
|
||||
|
|
||||
## grid 2
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
]])
|
||||
else
|
||||
screen:expect([[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end
|
||||
end)
|
||||
|
||||
it('API has proper error messages', function()
|
||||
|
||||
Reference in New Issue
Block a user