comparison src/window.c @ 31150:bcda71c89776 v9.0.0909

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)
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Nov 2022 14:15:03 +0100
parents f6d4c6a3b41c
children 514ab6bdf73d
comparison
equal deleted inserted replaced
31149:b2cd9ed7d829 31150:bcda71c89776
109 --close_disallowed; 109 --close_disallowed;
110 } 110 }
111 111
112 /* 112 /*
113 * When the window layout cannot be changed give an error and return TRUE. 113 * 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.
114 */ 116 */
115 int 117 int
116 window_layout_locked(void) 118 window_layout_locked(enum CMD_index cmd)
117 { 119 {
118 if (split_disallowed > 0 || close_disallowed > 0) 120 if (split_disallowed > 0 || close_disallowed > 0)
119 { 121 {
120 if (close_disallowed == 0) 122 if (close_disallowed == 0 && cmd == CMD_tabnew)
121 emsg(_(e_cannot_split_window_when_closing_buffer)); 123 emsg(_(e_cannot_split_window_when_closing_buffer));
122 else 124 else
123 emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd)); 125 emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd));
124 return TRUE; 126 return TRUE;
125 } 127 }
2571 if (last_window()) 2573 if (last_window())
2572 { 2574 {
2573 emsg(_(e_cannot_close_last_window)); 2575 emsg(_(e_cannot_close_last_window));
2574 return FAIL; 2576 return FAIL;
2575 } 2577 }
2576 if (window_layout_locked()) 2578 if (window_layout_locked(CMD_close))
2577 return FAIL; 2579 return FAIL;
2578 2580
2579 if (win->w_closing || (win->w_buffer != NULL 2581 if (win->w_closing || (win->w_buffer != NULL
2580 && win->w_buffer->b_locked > 0)) 2582 && win->w_buffer->b_locked > 0))
2581 return FAIL; // window is already being closed 2583 return FAIL; // window is already being closed
4060 if (cmdwin_type != 0) 4062 if (cmdwin_type != 0)
4061 { 4063 {
4062 emsg(_(e_invalid_in_cmdline_window)); 4064 emsg(_(e_invalid_in_cmdline_window));
4063 return FAIL; 4065 return FAIL;
4064 } 4066 }
4065 if (window_layout_locked()) 4067 if (window_layout_locked(CMD_tabnew))
4066 return FAIL; 4068 return FAIL;
4067 4069
4068 newtp = alloc_tabpage(); 4070 newtp = alloc_tabpage();
4069 if (newtp == NULL) 4071 if (newtp == NULL)
4070 return FAIL; 4072 return FAIL;