+32
-11
lines changedFilter options
+32
-11
lines changed Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(float_config) *config, E
150
150
if (!parse_float_config(config, &fconfig, false, true, err)) {
151
151
return 0;
152
152
}
153
-
win_T *wp = win_new_float(NULL, fconfig, err);
153
+
win_T *wp = win_new_float(NULL, false, fconfig, err);
154
154
if (!wp) {
155
155
return 0;
156
156
}
@@ -200,7 +200,7 @@ void nvim_win_set_config(Window window, Dict(float_config) *config, Error *err)
200
200
return;
201
201
}
202
202
if (new_float) {
203
-
if (!win_new_float(win, fconfig, err)) {
203
+
if (!win_new_float(win, false, fconfig, err)) {
204
204
return;
205
205
}
206
206
redraw_later(win, NOT_VALID);
Original file line number Diff line number Diff line change
@@ -560,7 +560,7 @@ void do_window(int nchar, long Prenum, int xchar)
560
560
config.height = curwin->w_height;
561
561
config.external = true;
562
562
Error err = ERROR_INIT;
563
-
if (!win_new_float(curwin, config, &err)) {
563
+
if (!win_new_float(curwin, false, config, &err)) {
564
564
emsg(err.msg);
565
565
api_clear_error(&err);
566
566
beep_flush();
@@ -629,16 +629,18 @@ void win_set_buf(Window window, Buffer buffer, bool noautocmd, Error *err)
629
629
630
630
/// Create a new float.
631
631
///
632
-
/// if wp == NULL allocate a new window, otherwise turn existing window into a
633
-
/// float. It must then already belong to the current tabpage!
634
-
///
635
-
/// config must already have been validated!
636
-
win_T *win_new_float(win_T *wp, FloatConfig fconfig, Error *err)
632
+
/// @param wp if NULL, allocate a new window, otherwise turn existing window into a float.
633
+
/// It must then already belong to the current tabpage!
634
+
/// @param last make the window the last one in the window list.
635
+
/// Only used when allocating the autocommand window.
636
+
/// @param config must already have been validated!
637
+
win_T *win_new_float(win_T *wp, bool last, FloatConfig fconfig, Error *err)
637
638
{
638
639
if (wp == NULL) {
639
-
wp = win_alloc(lastwin_nofloating(), false);
640
+
wp = win_alloc(last ? lastwin : lastwin_nofloating(), false);
640
641
win_init(wp, curwin, 0);
641
642
} else {
643
+
assert(!last);
642
644
assert(!wp->w_floating);
643
645
if (firstwin == wp && lastwin_nofloating() == wp) {
644
646
// last non-float
@@ -2543,7 +2545,7 @@ int win_close(win_T *win, bool free_buf, bool force)
2543
2545
emsg(_(e_autocmd_close));
2544
2546
return FAIL;
2545
2547
}
2546
-
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) {
2548
+
if (lastwin == aucmd_win && one_window()) {
2547
2549
emsg(_("E814: Cannot close window, only autocmd window would remain"));
2548
2550
return FAIL;
2549
2551
}
@@ -3844,7 +3846,7 @@ void win_alloc_aucmd_win(void)
3844
3846
fconfig.width = Columns;
3845
3847
fconfig.height = 5;
3846
3848
fconfig.focusable = false;
3847
-
aucmd_win = win_new_float(NULL, fconfig, &err);
3849
+
aucmd_win = win_new_float(NULL, true, fconfig, &err);
3848
3850
aucmd_win->w_buffer->b_nwindows--;
3849
3851
RESET_BINDING(aucmd_win);
3850
3852
}
Original file line number Diff line number Diff line change
@@ -398,6 +398,25 @@ describe('autocmd', function()
398
398
]])
399
399
end)
400
400
401
+
describe('closing last non-floating window in tab from `aucmd_win`', function()
402
+
before_each(function()
403
+
command('edit Xa.txt')
404
+
command('tabnew Xb.txt')
405
+
command('autocmd BufAdd Xa.txt 1close')
406
+
end)
407
+
408
+
it('gives E814 when there are no other floating windows', function()
409
+
eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
410
+
pcall_err(command, 'doautoall BufAdd'))
411
+
end)
412
+
413
+
it('gives E814 when there are other floating windows', function()
414
+
meths.open_win(0, true, {width = 10, height = 10, relative = 'editor', row = 10, col = 10})
415
+
eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
416
+
pcall_err(command, 'doautoall BufAdd'))
417
+
end)
418
+
end)
419
+
401
420
it(':doautocmd does not warn "No matching autocommands" #10689', function()
402
421
local screen = Screen.new(32, 3)
403
422
screen:attach()
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4