Mercurial > vim
comparison src/window.c @ 27805:afbe86e8b24a v8.2.4428
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Commit: https://github.com/vim/vim/commit/0f6e28f686dbb59ab3b562408ab9b2234797b9b1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 20 20:49:35 2022 +0000
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Problem: Crash when switching tabpage while in the cmdline window.
Solution: Disallow switching tabpage when in the cmdline window.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 20 Feb 2022 22:00:03 +0100 |
parents | c1d1639b52dd |
children | 126826449b54 |
comparison
equal
deleted
inserted
replaced
27804:8fc68ce4a097 | 27805:afbe86e8b24a |
---|---|
107 } | 107 } |
108 if (frame->fr_next != NULL) | 108 if (frame->fr_next != NULL) |
109 log_frame_layout(frame->fr_next); | 109 log_frame_layout(frame->fr_next); |
110 } | 110 } |
111 #endif | 111 #endif |
112 | |
113 /* | |
114 * Return the current window, unless in the cmdline window and "prevwin" is | |
115 * set, then return "prevwin". | |
116 */ | |
117 win_T * | |
118 prevwin_curwin(void) | |
119 { | |
120 return | |
121 #ifdef FEAT_CMDWIN | |
122 // In cmdwin, the alternative buffer should be used. | |
123 is_in_cmdwin() && prevwin != NULL ? prevwin : | |
124 #endif | |
125 curwin; | |
126 } | |
112 | 127 |
113 /* | 128 /* |
114 * All CTRL-W window commands are handled here, called from normal_cmd(). | 129 * All CTRL-W window commands are handled here, called from normal_cmd(). |
115 */ | 130 */ |
116 void | 131 void |
3925 tabpage_T *tp = curtab; | 3940 tabpage_T *tp = curtab; |
3926 tabpage_T *prev_tp = curtab; | 3941 tabpage_T *prev_tp = curtab; |
3927 tabpage_T *newtp; | 3942 tabpage_T *newtp; |
3928 int n; | 3943 int n; |
3929 | 3944 |
3945 #ifdef FEAT_CMDWIN | |
3946 if (cmdwin_type != 0) | |
3947 { | |
3948 emsg(_(e_invalid_in_cmdline_window)); | |
3949 return FAIL; | |
3950 } | |
3951 #endif | |
3952 | |
3930 newtp = alloc_tabpage(); | 3953 newtp = alloc_tabpage(); |
3931 if (newtp == NULL) | 3954 if (newtp == NULL) |
3932 return FAIL; | 3955 return FAIL; |
3933 | 3956 |
3934 // Remember the current windows in this Tab page. | 3957 // Remember the current windows in this Tab page. |
4299 { | 4322 { |
4300 // Not allowed when editing the command line. | 4323 // Not allowed when editing the command line. |
4301 text_locked_msg(); | 4324 text_locked_msg(); |
4302 return; | 4325 return; |
4303 } | 4326 } |
4327 CHECK_CMDWIN; | |
4304 | 4328 |
4305 // If there is only one it can't work. | 4329 // If there is only one it can't work. |
4306 if (first_tabpage->tp_next == NULL) | 4330 if (first_tabpage->tp_next == NULL) |
4307 { | 4331 { |
4308 if (n > 1) | 4332 if (n > 1) |
4366 goto_tabpage_tp( | 4390 goto_tabpage_tp( |
4367 tabpage_T *tp, | 4391 tabpage_T *tp, |
4368 int trigger_enter_autocmds, | 4392 int trigger_enter_autocmds, |
4369 int trigger_leave_autocmds) | 4393 int trigger_leave_autocmds) |
4370 { | 4394 { |
4395 CHECK_CMDWIN; | |
4396 | |
4371 // Don't repeat a message in another tab page. | 4397 // Don't repeat a message in another tab page. |
4372 set_keep_msg(NULL, 0); | 4398 set_keep_msg(NULL, 0); |
4373 | 4399 |
4374 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, | 4400 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, |
4375 trigger_leave_autocmds) == OK) | 4401 trigger_leave_autocmds) == OK) |