To: vim_dev@googlegroups.com Subject: Patch 9.0.0909 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0909 Problem: Error message for layout change does not match action. Solution: Pass the command to where the error is given. (closes #11573) Files: src/ex_docmd.c, src/window.c, src/proto/window.pro, src/testdir/test_autocmd.vim *** ../vim-9.0.0908/src/ex_docmd.c 2022-11-19 11:41:26.345764390 +0000 --- src/ex_docmd.c 2022-11-19 13:08:38.278188875 +0000 *************** *** 6055,6061 **** emsg(_(e_cannot_close_autocmd_or_popup_window)); return; } ! if (window_layout_locked()) return; need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); --- 6055,6061 ---- emsg(_(e_cannot_close_autocmd_or_popup_window)); return; } ! if (window_layout_locked(CMD_close)) return; need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); *************** *** 6229,6235 **** cmdwin_result = K_IGNORE; else if (first_tabpage->tp_next == NULL) emsg(_(e_cannot_close_last_tab_page)); ! else if (!window_layout_locked()) { tab_number = get_tabpage_arg(eap); if (eap->errmsg == NULL) --- 6229,6235 ---- cmdwin_result = K_IGNORE; else if (first_tabpage->tp_next == NULL) emsg(_(e_cannot_close_last_tab_page)); ! else if (!window_layout_locked(CMD_tabclose)) { tab_number = get_tabpage_arg(eap); if (eap->errmsg == NULL) *************** *** 6265,6271 **** cmdwin_result = K_IGNORE; else if (first_tabpage->tp_next == NULL) msg(_("Already only one tab page")); ! else if (!window_layout_locked()) { tab_number = get_tabpage_arg(eap); if (eap->errmsg == NULL) --- 6265,6271 ---- cmdwin_result = K_IGNORE; else if (first_tabpage->tp_next == NULL) msg(_("Already only one tab page")); ! else if (!window_layout_locked(CMD_tabonly)) { tab_number = get_tabpage_arg(eap); if (eap->errmsg == NULL) *************** *** 6298,6304 **** void tabpage_close(int forceit) { ! if (window_layout_locked()) return; // First close all the windows but the current one. If that worked then --- 6298,6304 ---- void tabpage_close(int forceit) { ! if (window_layout_locked(CMD_tabclose)) return; // First close all the windows but the current one. If that worked then *************** *** 6346,6352 **** static void ex_only(exarg_T *eap) { ! if (window_layout_locked()) return; # ifdef FEAT_GUI need_mouse_correct = TRUE; --- 6346,6352 ---- static void ex_only(exarg_T *eap) { ! if (window_layout_locked(CMD_only)) return; # ifdef FEAT_GUI need_mouse_correct = TRUE; *************** *** 6373,6379 **** // ":hide" or ":hide | cmd": hide current window if (!eap->skip) { ! if (window_layout_locked()) return; #ifdef FEAT_GUI need_mouse_correct = TRUE; --- 6373,6379 ---- // ":hide" or ":hide | cmd": hide current window if (!eap->skip) { ! if (window_layout_locked(CMD_hide)) return; #ifdef FEAT_GUI need_mouse_correct = TRUE; *** ../vim-9.0.0908/src/window.c 2022-11-19 11:41:26.341764390 +0000 --- src/window.c 2022-11-19 13:10:01.577947396 +0000 *************** *** 111,123 **** /* * When the window layout cannot be changed give an error and return TRUE. */ int ! window_layout_locked(void) { if (split_disallowed > 0 || close_disallowed > 0) { ! if (close_disallowed == 0) emsg(_(e_cannot_split_window_when_closing_buffer)); else emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd)); --- 111,125 ---- /* * 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(enum CMD_index cmd) { if (split_disallowed > 0 || 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)); *************** *** 2573,2579 **** emsg(_(e_cannot_close_last_window)); return FAIL; } ! if (window_layout_locked()) return FAIL; if (win->w_closing || (win->w_buffer != NULL --- 2575,2581 ---- emsg(_(e_cannot_close_last_window)); return FAIL; } ! if (window_layout_locked(CMD_close)) return FAIL; if (win->w_closing || (win->w_buffer != NULL *************** *** 4062,4068 **** emsg(_(e_invalid_in_cmdline_window)); return FAIL; } ! if (window_layout_locked()) return FAIL; newtp = alloc_tabpage(); --- 4064,4070 ---- emsg(_(e_invalid_in_cmdline_window)); return FAIL; } ! if (window_layout_locked(CMD_tabnew)) return FAIL; newtp = alloc_tabpage(); *** ../vim-9.0.0908/src/proto/window.pro 2022-11-19 11:41:26.341764390 +0000 --- src/proto/window.pro 2022-11-19 13:07:15.966455690 +0000 *************** *** 1,5 **** /* window.c */ ! int window_layout_locked(void); 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); --- 1,5 ---- /* window.c */ ! 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); *** ../vim-9.0.0908/src/testdir/test_autocmd.vim 2022-11-13 17:53:42.283417583 +0000 --- src/testdir/test_autocmd.vim 2022-11-19 13:12:06.517629819 +0000 *************** *** 756,761 **** --- 756,769 ---- bwipe! au! BufEnter endfor + + new + new + autocmd BufEnter * ++once close + call assert_fails('close', 'E1312:') + + au! BufEnter + only endfunc " Closing a window might cause an endless loop *** ../vim-9.0.0908/src/version.c 2022-11-19 12:24:39.762174332 +0000 --- src/version.c 2022-11-19 13:05:07.486940126 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 909, /**/ -- The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change. -- FORTRAN manual for Xerox Computers /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///