Problem: Getting tab-local variable fails after closing window.
Solution: set tp_firstwin and tp_lastwin. (Jason Franklin, closes #2170)
/* Set tp to be our tabpage, temporarily. Also set the window to the
* first window in the tabpage, otherwise the window is not valid. */
if (switch_win(&oldcurwin, &oldtabpage,
- tp->tp_firstwin == NULL ? firstwin : tp->tp_firstwin, tp, TRUE)
- == OK)
+ tp == curtab || tp->tp_firstwin == NULL ? firstwin
+ : tp->tp_firstwin, tp, TRUE) == OK)
{
/* look up the variable */
/* Let gettabvar({nr}, "") return the "t:" dictionary. */
call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
tabonly
endfunc
+
+" It was discovered that "gettabvar()" would fail if called from within the
+" tabline when the user closed a window. This test confirms the fix.
+func Test_gettabvar_in_tabline()
+ let t:var_str = 'value'
+
+ set tabline=%{assert_equal('value',gettabvar(1,'var_str'))}
+ set showtabline=2
+
+ " Simulate the user opening a split (which becomes window #1) and then
+ " closing the split, which triggers the redrawing of the tabline.
+ leftabove split
+ redrawstatus!
+ close
+ redrawstatus!
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1160,
/**/
1159,
/**/
if (wp->w_prev != NULL)
wp->w_prev->w_next = wp->w_next;
else if (tp == NULL)
- firstwin = wp->w_next;
+ firstwin = curtab->tp_firstwin = wp->w_next;
else
tp->tp_firstwin = wp->w_next;
+
if (wp->w_next != NULL)
wp->w_next->w_prev = wp->w_prev;
else if (tp == NULL)
- lastwin = wp->w_prev;
+ lastwin = curtab->tp_lastwin = wp->w_prev;
else
tp->tp_lastwin = wp->w_prev;
}
*/
int
switch_win(
- win_T **save_curwin UNUSED,
- tabpage_T **save_curtab UNUSED,
- win_T *win UNUSED,
- tabpage_T *tp UNUSED,
- int no_display UNUSED)
+ win_T **save_curwin,
+ tabpage_T **save_curtab,
+ win_T *win,
+ tabpage_T *tp,
+ int no_display)
{
# ifdef FEAT_AUTOCMD
block_autocmds();