Patch 8.2.4428
Problem: Crash when switching tabpage while in the cmdline window.
Solution: Disallow switching tabpage when in the cmdline window.
Files: src/window.c, src/proto/
window.pro, src/evalvars.c,
src/evalvars.c, src/usercmd.c
*** ../vim-8.2.4427/src/window.c 2022-02-16 19:24:03.630162410 +0000
--- src/window.c 2022-02-20 20:44:58.446654555 +0000
***************
*** 111,116 ****
--- 111,131 ----
#endif
/*
+ * Return the current window, unless in the cmdline window and "prevwin" is
+ * set, then return "prevwin".
+ */
+ win_T *
+ prevwin_curwin(void)
+ {
+ return
+ #ifdef FEAT_CMDWIN
+ // In cmdwin, the alternative buffer should be used.
+ is_in_cmdwin() && prevwin != NULL ? prevwin :
+ #endif
+ curwin;
+ }
+
+ /*
* All CTRL-W window commands are handled here, called from normal_cmd().
*/
void
***************
*** 3927,3932 ****
--- 3942,3955 ----
tabpage_T *newtp;
int n;
+ #ifdef FEAT_CMDWIN
+ if (cmdwin_type != 0)
+ {
+ emsg(_(e_invalid_in_cmdline_window));
+ return FAIL;
+ }
+ #endif
+
newtp = alloc_tabpage();
if (newtp == NULL)
return FAIL;
***************
*** 4301,4306 ****
--- 4324,4330 ----
text_locked_msg();
return;
}
+ CHECK_CMDWIN;
// If there is only one it can't work.
if (first_tabpage->tp_next == NULL)
***************
*** 4368,4373 ****
--- 4392,4399 ----
int trigger_enter_autocmds,
int trigger_leave_autocmds)
{
+ CHECK_CMDWIN;
+
// Don't repeat a message in another tab page.
set_keep_msg(NULL, 0);
*** ../vim-8.2.4427/src/proto/
window.pro 2022-01-08 18:43:36.877446896 +0000
--- src/proto/
window.pro 2022-02-20 20:31:30.044596338 +0000
***************
*** 1,4 ****
--- 1,5 ----
/* window.c */
+ 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);
int win_split(int size, int flags);
*** ../vim-8.2.4427/src/evalvars.c 2022-02-15 21:17:53.144747999 +0000
--- src/evalvars.c 2022-02-20 20:32:20.256487950 +0000
***************
*** 2199,2210 ****
}
// b: variables
! ht =
! #ifdef FEAT_CMDWIN
! // In cmdwin, the alternative buffer should be used.
! is_in_cmdwin() ? &prevwin->w_buffer->b_vars->dv_hashtab :
! #endif
! &curbuf->b_vars->dv_hashtab;
if (bdone < ht->ht_used)
{
if (bdone++ == 0)
--- 2199,2205 ----
}
// b: variables
! ht = &prevwin_curwin()->w_buffer->b_vars->dv_hashtab;
if (bdone < ht->ht_used)
{
if (bdone++ == 0)
***************
*** 2217,2228 ****
}
// w: variables
! ht =
! #ifdef FEAT_CMDWIN
! // In cmdwin, the alternative window should be used.
! is_in_cmdwin() ? &prevwin->w_vars->dv_hashtab :
! #endif
! &curwin->w_vars->dv_hashtab;
if (wdone < ht->ht_used)
{
if (wdone++ == 0)
--- 2212,2218 ----
}
// w: variables
! ht = &prevwin_curwin()->w_vars->dv_hashtab;
if (wdone < ht->ht_used)
{
if (wdone++ == 0)
*** ../vim-8.2.4427/src/evalvars.c 2022-02-15 21:17:53.144747999 +0000
--- src/evalvars.c 2022-02-20 20:32:20.256487950 +0000
***************
*** 2199,2210 ****
}
// b: variables
! ht =
! #ifdef FEAT_CMDWIN
! // In cmdwin, the alternative buffer should be used.
! is_in_cmdwin() ? &prevwin->w_buffer->b_vars->dv_hashtab :
! #endif
! &curbuf->b_vars->dv_hashtab;
if (bdone < ht->ht_used)
{
if (bdone++ == 0)
--- 2199,2205 ----
}
// b: variables
! ht = &prevwin_curwin()->w_buffer->b_vars->dv_hashtab;
if (bdone < ht->ht_used)
{
if (bdone++ == 0)
***************
*** 2217,2228 ****
}
// w: variables
! ht =
! #ifdef FEAT_CMDWIN
! // In cmdwin, the alternative window should be used.
! is_in_cmdwin() ? &prevwin->w_vars->dv_hashtab :
! #endif
! &curwin->w_vars->dv_hashtab;
if (wdone < ht->ht_used)
{
if (wdone++ == 0)
--- 2212,2218 ----
}
// w: variables
! ht = &prevwin_curwin()->w_vars->dv_hashtab;
if (wdone < ht->ht_used)
{
if (wdone++ == 0)
*** ../vim-8.2.4427/src/usercmd.c 2022-02-18 13:56:34.630118479 +0000
--- src/usercmd.c 2022-02-20 20:30:09.696770226 +0000
***************
*** 141,151 ****
/*
* Look for buffer-local user commands first, then global ones.
*/
! gap =
! #ifdef FEAT_CMDWIN
! is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :
! #endif
! &curbuf->b_ucmds;
for (;;)
{
for (j = 0; j < gap->ga_len; ++j)
--- 141,147 ----
/*
* Look for buffer-local user commands first, then global ones.
*/
! gap = &prevwin_curwin()->w_buffer->b_ucmds;
for (;;)
{
for (j = 0; j < gap->ga_len; ++j)
***************
*** 358,368 ****
get_user_commands(expand_T *xp UNUSED, int idx)
{
// In cmdwin, the alternative buffer should be used.
! buf_T *buf =
! #ifdef FEAT_CMDWIN
! is_in_cmdwin() ? prevwin->w_buffer :
! #endif
! curbuf;
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
--- 354,360 ----
get_user_commands(expand_T *xp UNUSED, int idx)
{
// In cmdwin, the alternative buffer should be used.
! buf_T *buf = prevwin_curwin()->w_buffer;
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
***************
*** 386,396 ****
if (cmdidx == CMD_USER_BUF)
{
// In cmdwin, the alternative buffer should be used.
! buf_T *buf =
! #ifdef FEAT_CMDWIN
! is_in_cmdwin() ? prevwin->w_buffer :
! #endif
! curbuf;
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
--- 378,384 ----
if (cmdidx == CMD_USER_BUF)
{
// In cmdwin, the alternative buffer should be used.
! buf_T *buf = prevwin_curwin()->w_buffer;
if (idx < buf->b_ucmds.ga_len)
return USER_CMD_GA(&buf->b_ucmds, idx)->uc_name;
***************
*** 478,488 ****
garray_T *gap;
// In cmdwin, the alternative buffer should be used.
! gap =
! #ifdef FEAT_CMDWIN
! is_in_cmdwin() ? &prevwin->w_buffer->b_ucmds :
! #endif
! &curbuf->b_ucmds;
for (;;)
{
for (i = 0; i < gap->ga_len; ++i)
--- 466,472 ----
garray_T *gap;
// In cmdwin, the alternative buffer should be used.
! gap = &prevwin_curwin()->w_buffer->b_ucmds;
for (;;)
{
for (i = 0; i < gap->ga_len; ++i)
*** ../vim-8.2.4427/src/version.c 2022-02-20 19:05:06.359955597 +0000
--- src/version.c 2022-02-20 20:47:38.854253272 +0000
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 4428,
/**/
--
hundred-and-one symptoms of being an internet addict:
87. Everyone you know asks why your phone line is always busy ...and
you tell them to send an e-mail.
/// Bram Moolenaar -- Br...@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 ///