Hi Vim!

On Fr, 21 Aug 2015, Vim Github Repository wrote:

> Hi!
> 
> Recently I've encountered an issue with Vim 7.4.712 on Mac OSX Yosemite. It 
> seems `gettabvar()` cannot read tab variables for the first time after Vim 
> start and after `:only` (or `<C-w>o`) if there was an unlisted buffer and got 
> closed. Here's how it behaves (and how to reproduce):
> 
> https://asciinema.org/a/emg1wb9ccmu72lhtoj62m8u6p
> 
> I can confirm the behavior with help buffer and `:only` command also on 
> MacVim 7.4.769.
> 
> Interestingly, after first attempt (when the empty string is returned) the 
> next call returns the variable value as expected.
> 
> Thanks in advance! And welcome to Github :)

Attached is a patch including a test.

Best,
Christian
-- 
Laut Statistik sind 100% aller Hausfrauen weiblich.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -12291,7 +12291,8 @@ f_gettabvar(argvars, rettv)
     {
 	/* 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, tp, TRUE)
+	if (switch_win(&oldcurwin, &oldtabpage,
+		    tp->tp_firstwin == NULL ? firstwin : tp->tp_firstwin, tp, TRUE)
 									== OK)
 	{
 	    /* look up the variable */
diff --git a/src/testdir/test91.in b/src/testdir/test91.in
--- a/src/testdir/test91.in
+++ b/src/testdir/test91.in
@@ -5,8 +5,12 @@ STARTTEST
 :so small.vim
 :so mbyte.vim
 :"
+:" Use strings to test for memory leaks.
+:" First, check that in an empty window, gettabvar() returns the correct value
+:let t:testvar='abcd'
+:$put =string(gettabvar(1,'testvar'))
+:$put =string(gettabvar(1,'testvar'))
 :" Test for getbufvar()
-:" Use strings to test for memory leaks.
 :let b:var_num = '1234'
 :let def_num = '5678'
 :$put =string(getbufvar(1, 'var_num'))
diff --git a/src/testdir/test91.ok b/src/testdir/test91.ok
--- a/src/testdir/test91.ok
+++ b/src/testdir/test91.ok
@@ -1,4 +1,6 @@
 start:
+'abcd'
+'abcd'
 '1234'
 '1234'
 {'var_num': '1234'}

Raspunde prin e-mail lui