0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.0.1160: getting tab-local variable fails after closing window

Problem:    Getting tab-local variable fails after closing window.
Solution:   set tp_firstwin and tp_lastwin. (Jason Franklin, closes #2170)
This commit is contained in:
Bram Moolenaar
2017-09-29 21:29:18 +02:00
parent d371bbe0ab
commit 816968defc
4 changed files with 28 additions and 9 deletions

View File

@@ -5183,8 +5183,8 @@ f_gettabvar(typval_T *argvars, typval_T *rettv)
/* Set tp to be our tabpage, temporarily. Also set the window to the /* Set tp to be our tabpage, temporarily. Also set the window to the
* first window in the tabpage, otherwise the window is not valid. */ * first window in the tabpage, otherwise the window is not valid. */
if (switch_win(&oldcurwin, &oldtabpage, if (switch_win(&oldcurwin, &oldtabpage,
tp->tp_firstwin == NULL ? firstwin : tp->tp_firstwin, tp, TRUE) tp == curtab || tp->tp_firstwin == NULL ? firstwin
== OK) : tp->tp_firstwin, tp, TRUE) == OK)
{ {
/* look up the variable */ /* look up the variable */
/* Let gettabvar({nr}, "") return the "t:" dictionary. */ /* Let gettabvar({nr}, "") return the "t:" dictionary. */

View File

@@ -86,3 +86,19 @@ func Test_var()
call assert_equal(1, gettabwinvar(2, 3, '&nux', 1)) call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
tabonly tabonly
endfunc 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

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1160,
/**/ /**/
1159, 1159,
/**/ /**/

View File

@@ -4775,13 +4775,14 @@ win_remove(
if (wp->w_prev != NULL) if (wp->w_prev != NULL)
wp->w_prev->w_next = wp->w_next; wp->w_prev->w_next = wp->w_next;
else if (tp == NULL) else if (tp == NULL)
firstwin = wp->w_next; firstwin = curtab->tp_firstwin = wp->w_next;
else else
tp->tp_firstwin = wp->w_next; tp->tp_firstwin = wp->w_next;
if (wp->w_next != NULL) if (wp->w_next != NULL)
wp->w_next->w_prev = wp->w_prev; wp->w_next->w_prev = wp->w_prev;
else if (tp == NULL) else if (tp == NULL)
lastwin = wp->w_prev; lastwin = curtab->tp_lastwin = wp->w_prev;
else else
tp->tp_lastwin = wp->w_prev; tp->tp_lastwin = wp->w_prev;
} }
@@ -6597,11 +6598,11 @@ restore_snapshot_rec(frame_T *sn, frame_T *fr)
*/ */
int int
switch_win( switch_win(
win_T **save_curwin UNUSED, win_T **save_curwin,
tabpage_T **save_curtab UNUSED, tabpage_T **save_curtab,
win_T *win UNUSED, win_T *win,
tabpage_T *tp UNUSED, tabpage_T *tp,
int no_display UNUSED) int no_display)
{ {
# ifdef FEAT_AUTOCMD # ifdef FEAT_AUTOCMD
block_autocmds(); block_autocmds();