aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-07-14 11:20:59 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-06 21:56:38 -0400
commit059986e03827c24e2fa1ac2a3b66743dfed9a8d9 (patch)
tree5ce912423f7fbe4f666d78630c7ee412e50bd683
parentd6711685747681e006f996893e85c998d192b2eb (diff)
downloadrneovim-059986e03827c24e2fa1ac2a3b66743dfed9a8d9.tar.gz
rneovim-059986e03827c24e2fa1ac2a3b66743dfed9a8d9.tar.bz2
rneovim-059986e03827c24e2fa1ac2a3b66743dfed9a8d9.zip
vim-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 vim/vim#2170) https://github.com/vim/vim/commit/816968defc8ae79eb7e2319e991e74661be8d750
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/testdir/test_getvar.vim16
-rw-r--r--src/nvim/window.c18
3 files changed, 28 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3abc39e7bf..b495e591d2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10222,7 +10222,8 @@ static void f_gettabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (tp != NULL && varname != NULL) {
// Set tp to be our tabpage, temporarily. Also set the window to the
// first window in the tabpage, otherwise the window is not valid.
- win_T *window = tp->tp_firstwin == NULL ? firstwin : tp->tp_firstwin;
+ win_T *window = tp == curtab || tp->tp_firstwin == NULL ? firstwin
+ : tp->tp_firstwin;
if (switch_win(&oldcurwin, &oldtabpage, window, tp, true) == OK) {
// look up the variable
// Let gettabvar({nr}, "") return the "t:" dictionary.
diff --git a/src/nvim/testdir/test_getvar.vim b/src/nvim/testdir/test_getvar.vim
index 0f5dff5d10..d6b6b69aa8 100644
--- a/src/nvim/testdir/test_getvar.vim
+++ b/src/nvim/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
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 7582c837c8..300514f424 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -3970,18 +3970,20 @@ win_remove (
tabpage_T *tp /* tab page "win" is in, NULL for current */
)
{
- if (wp->w_prev != NULL)
+ if (wp->w_prev != NULL) {
wp->w_prev->w_next = wp->w_next;
- else if (tp == NULL)
- firstwin = wp->w_next;
- else
+ } else if (tp == NULL) {
+ firstwin = curtab->tp_firstwin = wp->w_next;
+ } else {
tp->tp_firstwin = wp->w_next;
- if (wp->w_next != NULL)
+ }
+ if (wp->w_next != NULL) {
wp->w_next->w_prev = wp->w_prev;
- else if (tp == NULL)
- lastwin = wp->w_prev;
- else
+ } else if (tp == NULL) {
+ lastwin = curtab->tp_lastwin = wp->w_prev;
+ } else {
tp->tp_lastwin = wp->w_prev;
+ }
}
/*