• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionbcda71c8977605ed2052a70008b571fa5fca9808 (tree)
Time2022-11-19 22:15:03
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0909: error message for layout change does not match action

Commit: https://github.com/vim/vim/commit/9fda81515b26ecd3c1e99f95334aaed3f7b6fea3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 19 13:14:10 2022 +0000

patch 9.0.0909: error message for layout change does not match action
Problem: Error message for layout change does not match action.
Solution: Pass the command to where the error is given. (closes https://github.com/vim/vim/issues/11573)

Change Summary

Incremental Difference

diff -r b2cd9ed7d829 -r bcda71c89776 src/ex_docmd.c
--- a/src/ex_docmd.c Sat Nov 19 13:30:05 2022 +0100
+++ b/src/ex_docmd.c Sat Nov 19 14:15:03 2022 +0100
@@ -6055,7 +6055,7 @@
60556055 emsg(_(e_cannot_close_autocmd_or_popup_window));
60566056 return;
60576057 }
6058- if (window_layout_locked())
6058+ if (window_layout_locked(CMD_close))
60596059 return;
60606060
60616061 need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
@@ -6229,7 +6229,7 @@
62296229 cmdwin_result = K_IGNORE;
62306230 else if (first_tabpage->tp_next == NULL)
62316231 emsg(_(e_cannot_close_last_tab_page));
6232- else if (!window_layout_locked())
6232+ else if (!window_layout_locked(CMD_tabclose))
62336233 {
62346234 tab_number = get_tabpage_arg(eap);
62356235 if (eap->errmsg == NULL)
@@ -6265,7 +6265,7 @@
62656265 cmdwin_result = K_IGNORE;
62666266 else if (first_tabpage->tp_next == NULL)
62676267 msg(_("Already only one tab page"));
6268- else if (!window_layout_locked())
6268+ else if (!window_layout_locked(CMD_tabonly))
62696269 {
62706270 tab_number = get_tabpage_arg(eap);
62716271 if (eap->errmsg == NULL)
@@ -6298,7 +6298,7 @@
62986298 void
62996299 tabpage_close(int forceit)
63006300 {
6301- if (window_layout_locked())
6301+ if (window_layout_locked(CMD_tabclose))
63026302 return;
63036303
63046304 // First close all the windows but the current one. If that worked then
@@ -6346,7 +6346,7 @@
63466346 static void
63476347 ex_only(exarg_T *eap)
63486348 {
6349- if (window_layout_locked())
6349+ if (window_layout_locked(CMD_only))
63506350 return;
63516351 # ifdef FEAT_GUI
63526352 need_mouse_correct = TRUE;
@@ -6373,7 +6373,7 @@
63736373 // ":hide" or ":hide | cmd": hide current window
63746374 if (!eap->skip)
63756375 {
6376- if (window_layout_locked())
6376+ if (window_layout_locked(CMD_hide))
63776377 return;
63786378 #ifdef FEAT_GUI
63796379 need_mouse_correct = TRUE;
diff -r b2cd9ed7d829 -r bcda71c89776 src/proto/window.pro
--- a/src/proto/window.pro Sat Nov 19 13:30:05 2022 +0100
+++ b/src/proto/window.pro Sat Nov 19 14:15:03 2022 +0100
@@ -1,5 +1,5 @@
11 /* window.c */
2-int window_layout_locked(void);
2+int window_layout_locked(enum CMD_index cmd);
33 win_T *prevwin_curwin(void);
44 void do_window(int nchar, long Prenum, int xchar);
55 void get_wincmd_addr_type(char_u *arg, exarg_T *eap);
diff -r b2cd9ed7d829 -r bcda71c89776 src/testdir/test_autocmd.vim
--- a/src/testdir/test_autocmd.vim Sat Nov 19 13:30:05 2022 +0100
+++ b/src/testdir/test_autocmd.vim Sat Nov 19 14:15:03 2022 +0100
@@ -756,6 +756,14 @@
756756 bwipe!
757757 au! BufEnter
758758 endfor
759+
760+ new
761+ new
762+ autocmd BufEnter * ++once close
763+ call assert_fails('close', 'E1312:')
764+
765+ au! BufEnter
766+ only
759767 endfunc
760768
761769 " Closing a window might cause an endless loop
diff -r b2cd9ed7d829 -r bcda71c89776 src/version.c
--- a/src/version.c Sat Nov 19 13:30:05 2022 +0100
+++ b/src/version.c Sat Nov 19 14:15:03 2022 +0100
@@ -696,6 +696,8 @@
696696 static int included_patches[] =
697697 { /* Add new patch number below this line */
698698 /**/
699+ 909,
700+/**/
699701 908,
700702 /**/
701703 907,
diff -r b2cd9ed7d829 -r bcda71c89776 src/window.c
--- a/src/window.c Sat Nov 19 13:30:05 2022 +0100
+++ b/src/window.c Sat Nov 19 14:15:03 2022 +0100
@@ -111,13 +111,15 @@
111111
112112 /*
113113 * When the window layout cannot be changed give an error and return TRUE.
114+ * "cmd" indicates the action being performed and is used to pick the relevant
115+ * error message.
114116 */
115117 int
116-window_layout_locked(void)
118+window_layout_locked(enum CMD_index cmd)
117119 {
118120 if (split_disallowed > 0 || close_disallowed > 0)
119121 {
120- if (close_disallowed == 0)
122+ if (close_disallowed == 0 && cmd == CMD_tabnew)
121123 emsg(_(e_cannot_split_window_when_closing_buffer));
122124 else
123125 emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd));
@@ -2573,7 +2575,7 @@
25732575 emsg(_(e_cannot_close_last_window));
25742576 return FAIL;
25752577 }
2576- if (window_layout_locked())
2578+ if (window_layout_locked(CMD_close))
25772579 return FAIL;
25782580
25792581 if (win->w_closing || (win->w_buffer != NULL
@@ -4062,7 +4064,7 @@
40624064 emsg(_(e_invalid_in_cmdline_window));
40634065 return FAIL;
40644066 }
4065- if (window_layout_locked())
4067+ if (window_layout_locked(CMD_tabnew))
40664068 return FAIL;
40674069
40684070 newtp = alloc_tabpage();
Show on old repository browser