Mercurial > vim
changeset 12564:183dc24cf861 v8.0.1160
patch 8.0.1160: getting tab-local variable fails after closing window
commit https://github.com/vim/vim/commit/816968defc8ae79eb7e2319e991e74661be8d750
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 29 21:29:18 2017 +0200
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 https://github.com/vim/vim/issues/2170)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 29 Sep 2017 21:30:05 +0200 |
parents | b76fe12e988b |
children | 657abf4f50ba |
files | src/evalfunc.c src/testdir/test_getvar.vim src/version.c src/window.c |
diffstat | 4 files changed, 28 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5183,8 +5183,8 @@ f_gettabvar(typval_T *argvars, typval_T /* 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. */
--- a/src/testdir/test_getvar.vim +++ b/src/testdir/test_getvar.vim @@ -86,3 +86,19 @@ func Test_var() 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
--- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1160, +/**/ 1159, /**/ 1158,
--- a/src/window.c +++ b/src/window.c @@ -4775,13 +4775,14 @@ win_remove( 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; } @@ -6597,11 +6598,11 @@ restore_snapshot_rec(frame_T *sn, frame_ */ 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();