aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJurica Bradaric <jbradaric@gmail.com>2016-02-09 20:11:23 +0100
committerJurica Bradaric <jbradaric@gmail.com>2016-02-09 20:21:26 +0100
commitf19e4dd1df63d8185631107d1def1609dc5aad7a (patch)
tree0eddf125fd8a1e0d94ffa279134669df1ee5fbf7
parent3be74ac634e205e26874f75b9300d3e016a110d6 (diff)
downloadrneovim-f19e4dd1df63d8185631107d1def1609dc5aad7a.tar.gz
rneovim-f19e4dd1df63d8185631107d1def1609dc5aad7a.tar.bz2
rneovim-f19e4dd1df63d8185631107d1def1609dc5aad7a.zip
vim-patch:7.4.834
Problem: gettabvar() doesn't work after Vim start. (Szymon Wrozynski) Solution: Handle first window in tab still being NULL. (Christian Brabandt) https://github.com/vim/vim/commit/7e47d1ac6a9ae0e5a7167aa34ff651a9c39c1641
-rw-r--r--src/nvim/eval.c7
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/legacy/091_context_variables_spec.lua5
3 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 7ca1f1512e..b9b913a969 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10593,9 +10593,10 @@ static void f_gettabvar(typval_T *argvars, typval_T *rettv)
varname = get_tv_string_chk(&argvars[1]);
tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL));
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. */
- if (switch_win(&oldcurwin, &oldtabpage, tp->tp_firstwin, tp, TRUE) == OK) {
+ // 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;
+ if (switch_win(&oldcurwin, &oldtabpage, window, tp, true) == OK) {
// look up the variable
// Let gettabvar({nr}, "") return the "t:" dictionary.
v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE);
diff --git a/src/nvim/version.c b/src/nvim/version.c
index b9edea271e..269f9872d0 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -454,7 +454,7 @@ static int included_patches[] = {
// 837 NA
836,
// 835,
- // 834,
+ 834,
// 833,
// 832,
// 831,
diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua
index ffeb0c657e..2c46ef643c 100644
--- a/test/functional/legacy/091_context_variables_spec.lua
+++ b/test/functional/legacy/091_context_variables_spec.lua
@@ -13,6 +13,9 @@ describe('context variables', function()
-- Test for getbufvar().
-- Use strings to test for memory leaks.
source([[
+ let t:testvar='abcd'
+ $put =string(gettabvar(1, 'testvar'))
+ $put =string(gettabvar(1, 'testvar'))
let b:var_num = '1234'
let def_num = '5678'
$put =string(getbufvar(1, 'var_num'))
@@ -125,6 +128,8 @@ describe('context variables', function()
-- Assert buffer contents.
expect([[
start:
+ 'abcd'
+ 'abcd'
'1234'
'1234'
{'var_num': '1234'}