emsg(_(e_cannot_close_autocmd_or_popup_window));
return;
}
- if (window_layout_locked())
+ if (window_layout_locked(CMD_close))
return;
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
cmdwin_result = K_IGNORE;
else if (first_tabpage->tp_next == NULL)
emsg(_(e_cannot_close_last_tab_page));
- else if (!window_layout_locked())
+ else if (!window_layout_locked(CMD_tabclose))
{
tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL)
cmdwin_result = K_IGNORE;
else if (first_tabpage->tp_next == NULL)
msg(_("Already only one tab page"));
- else if (!window_layout_locked())
+ else if (!window_layout_locked(CMD_tabonly))
{
tab_number = get_tabpage_arg(eap);
if (eap->errmsg == NULL)
void
tabpage_close(int forceit)
{
- if (window_layout_locked())
+ if (window_layout_locked(CMD_tabclose))
return;
// First close all the windows but the current one. If that worked then
static void
ex_only(exarg_T *eap)
{
- if (window_layout_locked())
+ if (window_layout_locked(CMD_only))
return;
# ifdef FEAT_GUI
need_mouse_correct = TRUE;
// ":hide" or ":hide | cmd": hide current window
if (!eap->skip)
{
- if (window_layout_locked())
+ if (window_layout_locked(CMD_hide))
return;
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
/* window.c */
-int window_layout_locked(void);
+int window_layout_locked(enum CMD_index cmd);
win_T *prevwin_curwin(void);
void do_window(int nchar, long Prenum, int xchar);
void get_wincmd_addr_type(char_u *arg, exarg_T *eap);
/*
* When the window layout cannot be changed give an error and return TRUE.
+ * "cmd" indicates the action being performed and is used to pick the relevant
+ * error message.
*/
int
-window_layout_locked(void)
+window_layout_locked(enum CMD_index cmd)
{
if (split_disallowed > 0 || close_disallowed > 0)
{
- if (close_disallowed == 0)
+ if (close_disallowed == 0 && cmd == CMD_tabnew)
emsg(_(e_cannot_split_window_when_closing_buffer));
else
emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd));
emsg(_(e_cannot_close_last_window));
return FAIL;
}
- if (window_layout_locked())
+ if (window_layout_locked(CMD_close))
return FAIL;
if (win->w_closing || (win->w_buffer != NULL
emsg(_(e_invalid_in_cmdline_window));
return FAIL;
}
- if (window_layout_locked())
+ if (window_layout_locked(CMD_tabnew))
return FAIL;
newtp = alloc_tabpage();