Patch 8.2.0507 (after 8.2.0472)
Problem:    Getbufvar() may get the wrong dictionary. (David le Blanc)
Solution:   Check for empty name. (closes #5878)
Files:      src/evalvars.c, src/testdir/test_functions.vim


*** ../vim-8.2.0506/src/evalvars.c      2020-04-02 18:50:42.419773128 +0200
--- src/evalvars.c      2020-04-03 18:42:29.403241509 +0200
***************
*** 2382,2387 ****
--- 2382,2388 ----
  
  /*
   * 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 *
***************
*** 3503,3510 ****
        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 (v != NULL)
            {
                copy_tv(&v->di_tv, rettv);
--- 3504,3515 ----
        else
        {
            // Look up the variable.
!           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);
*** ../vim-8.2.0506/src/testdir/test_functions.vim      2020-03-26 
16:50:53.413148743 +0100
--- src/testdir/test_functions.vim      2020-04-03 18:39:47.435923188 +0200
***************
*** 841,846 ****
--- 841,856 ----
    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
  
*** ../vim-8.2.0506/src/version.c       2020-04-03 18:13:54.446315826 +0200
--- src/version.c       2020-04-03 18:42:48.387162157 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     507,
  /**/

-- 
ROBIN:  (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN:  Oh ... wacho!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202004031644.033Gi8x1017447%40masaka.moolenaar.net.

Raspunde prin e-mail lui