mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(aucmd_win): always make aucmd_win the last window
This commit is contained in:
parent
7735163652
commit
89712dcbf8
@ -150,7 +150,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E
|
||||
if (!parse_float_config(config, &fconfig, false, true, err)) {
|
||||
return 0;
|
||||
}
|
||||
win_T *wp = win_new_float(NULL, fconfig, err);
|
||||
win_T *wp = win_new_float(NULL, false, fconfig, err);
|
||||
if (!wp) {
|
||||
return 0;
|
||||
}
|
||||
@ -200,7 +200,7 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err)
|
||||
return;
|
||||
}
|
||||
if (new_float) {
|
||||
if (!win_new_float(win, fconfig, err)) {
|
||||
if (!win_new_float(win, false, fconfig, err)) {
|
||||
return;
|
||||
}
|
||||
redraw_later(win, NOT_VALID);
|
||||
|
@ -560,7 +560,7 @@ wingotofile:
|
||||
config.height = curwin->w_height;
|
||||
config.external = true;
|
||||
Error err = ERROR_INIT;
|
||||
if (!win_new_float(curwin, config, &err)) {
|
||||
if (!win_new_float(curwin, false, config, &err)) {
|
||||
emsg(err.msg);
|
||||
api_clear_error(&err);
|
||||
beep_flush();
|
||||
@ -629,16 +629,18 @@ void win_set_buf(Window window, Buffer buffer, bool noautocmd, Error *err)
|
||||
|
||||
/// Create a new float.
|
||||
///
|
||||
/// if wp == NULL allocate a new window, otherwise turn existing window into a
|
||||
/// float. It must then already belong to the current tabpage!
|
||||
///
|
||||
/// config must already have been validated!
|
||||
win_T *win_new_float(win_T *wp, FloatConfig fconfig, Error *err)
|
||||
/// @param wp if NULL, allocate a new window, otherwise turn existing window into a float.
|
||||
/// It must then already belong to the current tabpage!
|
||||
/// @param last make the window the last one in the window list.
|
||||
/// Only used when allocating the autocommand window.
|
||||
/// @param config must already have been validated!
|
||||
win_T *win_new_float(win_T *wp, bool last, FloatConfig fconfig, Error *err)
|
||||
{
|
||||
if (wp == NULL) {
|
||||
wp = win_alloc(lastwin_nofloating(), false);
|
||||
wp = win_alloc(last ? lastwin : lastwin_nofloating(), false);
|
||||
win_init(wp, curwin, 0);
|
||||
} else {
|
||||
assert(!last);
|
||||
assert(!wp->w_floating);
|
||||
if (firstwin == wp && lastwin_nofloating() == wp) {
|
||||
// last non-float
|
||||
@ -2543,7 +2545,7 @@ int win_close(win_T *win, bool free_buf, bool force)
|
||||
emsg(_(e_autocmd_close));
|
||||
return FAIL;
|
||||
}
|
||||
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) {
|
||||
if (lastwin == aucmd_win && one_window()) {
|
||||
emsg(_("E814: Cannot close window, only autocmd window would remain"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -3844,7 +3846,7 @@ void win_alloc_aucmd_win(void)
|
||||
fconfig.width = Columns;
|
||||
fconfig.height = 5;
|
||||
fconfig.focusable = false;
|
||||
aucmd_win = win_new_float(NULL, fconfig, &err);
|
||||
aucmd_win = win_new_float(NULL, true, fconfig, &err);
|
||||
aucmd_win->w_buffer->b_nwindows--;
|
||||
RESET_BINDING(aucmd_win);
|
||||
}
|
||||
|
@ -398,6 +398,25 @@ describe('autocmd', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
describe('closing last non-floating window in tab from `aucmd_win`', function()
|
||||
before_each(function()
|
||||
command('edit Xa.txt')
|
||||
command('tabnew Xb.txt')
|
||||
command('autocmd BufAdd Xa.txt 1close')
|
||||
end)
|
||||
|
||||
it('gives E814 when there are no other floating windows', function()
|
||||
eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
|
||||
pcall_err(command, 'doautoall BufAdd'))
|
||||
end)
|
||||
|
||||
it('gives E814 when there are other floating windows', function()
|
||||
meths.open_win(0, true, {width = 10, height = 10, relative = 'editor', row = 10, col = 10})
|
||||
eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
|
||||
pcall_err(command, 'doautoall BufAdd'))
|
||||
end)
|
||||
end)
|
||||
|
||||
it(':doautocmd does not warn "No matching autocommands" #10689', function()
|
||||
local screen = Screen.new(32, 3)
|
||||
screen:attach()
|
||||
|
Loading…
Reference in New Issue
Block a user