mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
API: nvim_win_close: Fix closing cmdline-window #10087
This commit is contained in:
parent
278c5d452c
commit
5f243fc68a
@ -6,6 +6,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include "nvim/ascii.h"
|
||||||
|
#include "nvim/globals.h"
|
||||||
#include "nvim/api/window.h"
|
#include "nvim/api/window.h"
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
@ -18,7 +20,6 @@
|
|||||||
#include "nvim/screen.h"
|
#include "nvim/screen.h"
|
||||||
#include "nvim/move.h"
|
#include "nvim/move.h"
|
||||||
|
|
||||||
|
|
||||||
/// Gets the current buffer in a window
|
/// Gets the current buffer in a window
|
||||||
///
|
///
|
||||||
/// @param window Window handle
|
/// @param window Window handle
|
||||||
@ -526,9 +527,7 @@ Dictionary nvim_win_get_config(Window window, Error *err)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close a window.
|
/// Closes the window (like |:close| with a |window-ID|).
|
||||||
///
|
|
||||||
/// This is equivalent to |:close| with count except that it takes a window id.
|
|
||||||
///
|
///
|
||||||
/// @param window Window handle
|
/// @param window Window handle
|
||||||
/// @param force Behave like `:close!` The last window of a buffer with
|
/// @param force Behave like `:close!` The last window of a buffer with
|
||||||
@ -546,6 +545,10 @@ void nvim_win_close(Window window, Boolean force, Error *err)
|
|||||||
|
|
||||||
TryState tstate;
|
TryState tstate;
|
||||||
try_enter(&tstate);
|
try_enter(&tstate);
|
||||||
|
if (cmdwin_type != 0 && win == curwin) {
|
||||||
|
cmdwin_result = Ctrl_C;
|
||||||
|
} else {
|
||||||
ex_win_close(force, win, tabpage == curtab ? NULL : tabpage);
|
ex_win_close(force, win, tabpage == curtab ? NULL : tabpage);
|
||||||
|
}
|
||||||
vim_ignored = try_leave(&tstate, err);
|
vim_ignored = try_leave(&tstate, err);
|
||||||
}
|
}
|
||||||
|
@ -322,5 +322,20 @@ describe('API/win', function()
|
|||||||
meths.win_close(oldwin,true)
|
meths.win_close(oldwin,true)
|
||||||
eq({newwin}, meths.list_wins())
|
eq({newwin}, meths.list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('in cmdline-window #9767', function()
|
||||||
|
command('split')
|
||||||
|
eq(2, #meths.list_wins())
|
||||||
|
-- Open cmdline-window.
|
||||||
|
feed('q:')
|
||||||
|
eq(3, #meths.list_wins())
|
||||||
|
eq(':', funcs.getcmdwintype())
|
||||||
|
-- Vim: not allowed to close other windows from cmdline-window.
|
||||||
|
expect_err('Invalid window id$', meths.win_close, 1, true)
|
||||||
|
-- Close cmdline-window.
|
||||||
|
meths.win_close(0,true)
|
||||||
|
eq(2, #meths.list_wins())
|
||||||
|
eq('', funcs.getcmdwintype())
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user