diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/arglist.c | 20 | ||||
-rw-r--r-- | src/nvim/autocmd.c | 3 | ||||
-rw-r--r-- | src/nvim/buffer.c | 30 | ||||
-rw-r--r-- | src/nvim/lua/stdlib.c | 3 | ||||
-rw-r--r-- | src/nvim/main.c | 3 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 3 |
6 files changed, 43 insertions, 19 deletions
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 74348052b0..9c2b3ba6d8 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -857,12 +857,17 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall) while (true) { win_T *wpnext = NULL; tabpage_T *tpnext = curtab->tp_next; - for (win_T *wp = firstwin; wp != NULL; wp = wpnext) { + // Try to close floating windows first + for (win_T *wp = lastwin->w_floating ? lastwin : firstwin; wp != NULL; wp = wpnext) { int i; - wpnext = wp->w_next; + wpnext = wp->w_floating + ? wp->w_prev->w_floating ? wp->w_prev : firstwin + : (wp->w_next == NULL || wp->w_next->w_floating) ? NULL : wp->w_next; buf_T *buf = wp->w_buffer; if (buf->b_ffname == NULL - || (!aall->keep_tabs && (buf->b_nwindows > 1 || wp->w_width != Columns))) { + || (!aall->keep_tabs + && (buf->b_nwindows > 1 || wp->w_width != Columns + || (wp->w_floating && !is_aucmd_win(wp))))) { i = aall->opened_len; } else { // check if the buffer in this window is in the arglist @@ -917,7 +922,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall) (void)autowrite(buf, false); // Check if autocommands removed the window. if (!win_valid(wp) || !bufref_valid(&bufref)) { - wpnext = firstwin; // Start all over... + wpnext = lastwin->w_floating ? lastwin : firstwin; // Start all over... continue; } } @@ -930,7 +935,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall) // check if autocommands removed the next window if (!win_valid(wpnext)) { // start all over... - wpnext = firstwin; + wpnext = lastwin->w_floating ? lastwin : firstwin; } } } @@ -977,6 +982,8 @@ static void arg_all_open_windows(arg_all_state_T *aall, int count) if (aall->keep_tabs) { aall->new_curwin = wp; aall->new_curtab = curtab; + } else if (wp->w_floating) { + break; } else if (wp->w_frame->fr_parent != curwin->w_frame->fr_parent) { emsg(_(e_window_layout_changed_unexpectedly)); i = count; @@ -1098,7 +1105,8 @@ static void do_arg_all(int count, int forceit, int keep_tabs) autocmd_no_leave++; last_curwin = curwin; last_curtab = curtab; - win_enter(lastwin, false); + // lastwin may be aucmd_win + win_enter(lastwin_nofloating(), false); // Open up to "count" windows. arg_all_open_windows(&aall, count); diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 3fa20f4e48..ff0c2f063f 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1341,7 +1341,6 @@ void aucmd_restbuf(aco_save_T *aco) if (aco->use_aucmd_win_idx >= 0) { win_T *awp = aucmd_win[aco->use_aucmd_win_idx].auc_win; - curbuf->b_nwindows--; // Find "awp", it can't be closed, but it may be in another tab page. // Do not trigger autocommands here. block_autocmds(); @@ -1357,7 +1356,7 @@ void aucmd_restbuf(aco_save_T *aco) } } win_found: - ; + curbuf->b_nwindows--; const bool save_stop_insert_mode = stop_insert_mode; // May need to stop Insert mode if we were in a prompt buffer. leaving_window(curwin); diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index d2a5eab0a5..68cef67c8a 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3616,21 +3616,28 @@ void ex_buffer_all(exarg_T *eap) } while (true) { tpnext = curtab->tp_next; - for (wp = firstwin; wp != NULL; wp = wpnext) { - wpnext = wp->w_next; + // Try to close floating windows first + for (wp = lastwin->w_floating ? lastwin : firstwin; wp != NULL; wp = wpnext) { + wpnext = wp->w_floating + ? wp->w_prev->w_floating ? wp->w_prev : firstwin + : (wp->w_next == NULL || wp->w_next->w_floating) ? NULL : wp->w_next; if ((wp->w_buffer->b_nwindows > 1 + || wp->w_floating || ((cmdmod.cmod_split & WSP_VERT) ? wp->w_height + wp->w_hsep_height + wp->w_status_height < Rows - p_ch - tabline_height() - global_stl_height() : wp->w_width != Columns) || (had_tab > 0 && wp != firstwin)) && !ONE_WINDOW - && !(wp->w_closing - || wp->w_buffer->b_locked > 0)) { - win_close(wp, false, false); - wpnext = firstwin; // just in case an autocommand does - // something strange with windows - tpnext = first_tabpage; // start all over... + && !(wp->w_closing || wp->w_buffer->b_locked > 0) + && !is_aucmd_win(wp)) { + if (win_close(wp, false, false) == FAIL) { + break; + } + // Just in case an autocommand does something strange with + // windows: start all over... + wpnext = lastwin->w_floating ? lastwin : firstwin; + tpnext = first_tabpage; open_wins = 0; } else { open_wins++; @@ -3650,7 +3657,8 @@ void ex_buffer_all(exarg_T *eap) // // Don't execute Win/Buf Enter/Leave autocommands here. autocmd_no_enter++; - win_enter(lastwin, false); + // lastwin may be aucmd_win + win_enter(lastwin_nofloating(), false); autocmd_no_leave++; for (buf = firstbuf; buf != NULL && open_wins < count; buf = buf->b_next) { // Check if this buffer needs a window @@ -3668,7 +3676,7 @@ void ex_buffer_all(exarg_T *eap) } else { // Check if this buffer already has a window for (wp = firstwin; wp != NULL; wp = wp->w_next) { - if (wp->w_buffer == buf) { + if (!wp->w_floating && wp->w_buffer == buf) { break; } } @@ -3742,7 +3750,7 @@ void ex_buffer_all(exarg_T *eap) // Close superfluous windows. for (wp = lastwin; open_wins > count;) { r = (buf_hide(wp->w_buffer) || !bufIsChanged(wp->w_buffer) - || autowrite(wp->w_buffer, false) == OK); + || autowrite(wp->w_buffer, false) == OK) && !is_aucmd_win(wp); if (!win_valid(wp)) { // BufWrite Autocommands made the window invalid, start over wp = lastwin; diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 4f9677650f..8f1b5c7b86 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -359,6 +359,9 @@ int nlua_setvar(lua_State *lstate) Error err = ERROR_INIT; dictitem_T *di = dict_check_writable(dict, key, del, &err); if (ERROR_SET(&err)) { + nlua_push_errstr(lstate, "%s", err.msg); + api_clear_error(&err); + lua_error(lstate); return 0; } diff --git a/src/nvim/main.c b/src/nvim/main.c index d9ca82784f..0bb69d000b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -659,6 +659,9 @@ void os_exit(int r) if (ui_client_channel_id) { ui_client_stop(); + if (r == 0) { + r = ui_client_exit_status; + } } else { ui_flush(); ui_call_stop(); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 4097b770c9..db15cdb053 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -386,6 +386,9 @@ static void terminfo_stop(TUIData *tui) unibi_out_ext(tui, tui->unibi_ext.disable_extended_keys); // May restore old title before exiting alternate screen. tui_set_title(tui, (String)STRING_INIT); + if (ui_client_exit_status == 0) { + ui_client_exit_status = tui->seen_error_exit; + } // if nvim exited with nonzero status, without indicated this was an // intentional exit (like `:1cquit`), it likely was an internal failure. // Don't clobber the stderr error message in this case. |