/*
* Find variable "varname" in hashtab "ht" with name "htname".
+ * When "varname" is empty returns curwin/curtab/etc vars dictionary.
* Returns NULL if not found.
*/
dictitem_T *
else
{
// Look up the variable.
- // Let getbufvar({nr}, "") return the "b:" dictionary.
- v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', varname, FALSE);
+ if (*varname == NUL)
+ // Let getbufvar({nr}, "") return the "b:" dictionary.
+ v = &buf->b_bufvar;
+ else
+ v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b',
+ varname, FALSE);
if (v != NULL)
{
copy_tv(&v->di_tv, rettv);
call assert_equal('iso-8859-2', getbufvar(bufnr('%'), '&fenc'))
close
+ " Get the b: dict.
+ let b:testvar = 'one'
+ new
+ let b:testvar = 'two'
+ let thebuf = bufnr()
+ wincmd w
+ call assert_equal('two', getbufvar(thebuf, 'testvar'))
+ call assert_equal('two', getbufvar(thebuf, '').testvar)
+ bwipe!
+
set fileformats&
endfunc