Patch 8.1.1919
Problem:    Using current window option values when passing a buffer to
            popup_create().
Solution:   Clear the window-local options. (closes #4857)
Files:      src/option.c, src/proto/option.pro, src/popupwin.c,
            src/testdir/test_popupwin.vim


*** ../vim-8.1.1918/src/option.c        2019-08-23 20:58:42.024375479 +0200
--- src/option.c        2019-08-24 15:40:09.076199788 +0200
***************
*** 3892,3900 ****
  /*
   * Set all window-local and buffer-local options to the Vim default.
   * local-global options will use the global value.
   */
      void
! set_local_options_default(win_T *wp)
  {
      win_T     *save_curwin = curwin;
      int               i;
--- 3892,3901 ----
  /*
   * Set all window-local and buffer-local options to the Vim default.
   * local-global options will use the global value.
+  * When "do_buffer" is FALSE don't set buffer-local options.
   */
      void
! set_local_options_default(win_T *wp, int do_buffer)
  {
      win_T     *save_curwin = curwin;
      int               i;
***************
*** 3909,3914 ****
--- 3910,3916 ----
        char_u              *varp = get_varp_scope(p, OPT_LOCAL);
  
        if (p->indir != PV_NONE
+               && (do_buffer || (p->indir & PV_BUF) == 0)
                && !(options[i].flags & P_NODEFAULT)
                && !optval_default(p, varp, FALSE))
            set_option_default(i, OPT_LOCAL, FALSE);
*** ../vim-8.1.1918/src/proto/option.pro        2019-08-20 20:13:40.330821936 
+0200
--- src/proto/option.pro        2019-08-24 15:38:31.052684347 +0200
***************
*** 2,8 ****
  void set_init_1(int clean_arg);
  void set_string_default(char *name, char_u *val);
  void set_number_default(char *name, long val);
! void set_local_options_default(win_T *wp);
  void free_all_options(void);
  void set_init_2(void);
  void set_init_3(void);
--- 2,8 ----
  void set_init_1(int clean_arg);
  void set_string_default(char *name, char_u *val);
  void set_number_default(char *name, long val);
! void set_local_options_default(win_T *wp, int do_buffer);
  void free_all_options(void);
  void set_init_2(void);
  void set_init_3(void);
*** ../vim-8.1.1918/src/popupwin.c      2019-08-24 15:26:21.388290137 +0200
--- src/popupwin.c      2019-08-24 15:46:27.430996426 +0200
***************
*** 1543,1548 ****
--- 1543,1549 ----
        // use existing buffer
        new_buffer = FALSE;
        win_init_popup_win(wp, buf);
+       set_local_options_default(wp, FALSE);
        buffer_ensure_loaded(buf);
      }
      else
***************
*** 1556,1562 ****
  
        win_init_popup_win(wp, buf);
  
!       set_local_options_default(wp);
        set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
                                     (char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
        set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
--- 1557,1563 ----
  
        win_init_popup_win(wp, buf);
  
!       set_local_options_default(wp, TRUE);
        set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
                                     (char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
        set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
*** ../vim-8.1.1918/src/testdir/test_popupwin.vim       2019-08-24 
14:46:26.208051433 +0200
--- src/testdir/test_popupwin.vim       2019-08-24 15:49:07.526454232 +0200
***************
*** 1814,1828 ****
--- 1814,1838 ----
    call writefile(['some text', 'in a buffer'], 'XsomeFile')
    let buf = bufadd('XsomeFile')
    call assert_equal(0, bufloaded(buf))
+ 
+   setlocal number
+   call setbufvar(buf, "&wrapmargin", 13)
+ 
    let winid = popup_create(buf, {})
    call assert_notequal(0, winid)
    let pos = popup_getpos(winid)
    call assert_equal(2, pos.height)
    call assert_equal(1, bufloaded(buf))
+ 
+   " window-local option is set to default, buffer-local is not
+   call assert_equal(0, getwinvar(winid, '&number'))
+   call assert_equal(13, getbufvar(buf, '&wrapmargin'))
+ 
    call popup_close(winid)
    call assert_equal({}, popup_getpos(winid))
    call assert_equal(1, bufloaded(buf))
    exe 'bwipe! ' .. buf
+   setlocal nonumber
  
    edit test_popupwin.vim
    let winid = popup_create(bufnr(''), {})
*** ../vim-8.1.1918/src/version.c       2019-08-24 15:26:21.388290137 +0200
--- src/version.c       2019-08-24 15:50:19.914192277 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1919,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
108. While reading a magazine, you look for the Zoom icon for a better
     look at a photograph.

 /// 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/201908241351.x7ODpDla017202%40masaka.moolenaar.net.

Raspunde prin e-mail lui