mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1919: using window options when passing a buffer to popup_create()
Problem: Using current window option values when passing a buffer to popup_create(). Solution: Clear the window-local options. (closes #4857)
This commit is contained in:
parent
e9a891f255
commit
4645104be4
@ -3892,9 +3892,10 @@ set_number_default(char *name, long val)
|
|||||||
/*
|
/*
|
||||||
* Set all window-local and buffer-local options to the Vim default.
|
* Set all window-local and buffer-local options to the Vim default.
|
||||||
* local-global options will use the global value.
|
* local-global options will use the global value.
|
||||||
|
* When "do_buffer" is FALSE don't set buffer-local options.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set_local_options_default(win_T *wp)
|
set_local_options_default(win_T *wp, int do_buffer)
|
||||||
{
|
{
|
||||||
win_T *save_curwin = curwin;
|
win_T *save_curwin = curwin;
|
||||||
int i;
|
int i;
|
||||||
@ -3909,6 +3910,7 @@ set_local_options_default(win_T *wp)
|
|||||||
char_u *varp = get_varp_scope(p, OPT_LOCAL);
|
char_u *varp = get_varp_scope(p, OPT_LOCAL);
|
||||||
|
|
||||||
if (p->indir != PV_NONE
|
if (p->indir != PV_NONE
|
||||||
|
&& (do_buffer || (p->indir & PV_BUF) == 0)
|
||||||
&& !(options[i].flags & P_NODEFAULT)
|
&& !(options[i].flags & P_NODEFAULT)
|
||||||
&& !optval_default(p, varp, FALSE))
|
&& !optval_default(p, varp, FALSE))
|
||||||
set_option_default(i, OPT_LOCAL, FALSE);
|
set_option_default(i, OPT_LOCAL, FALSE);
|
||||||
|
@ -1543,6 +1543,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
|
|||||||
// use existing buffer
|
// use existing buffer
|
||||||
new_buffer = FALSE;
|
new_buffer = FALSE;
|
||||||
win_init_popup_win(wp, buf);
|
win_init_popup_win(wp, buf);
|
||||||
|
set_local_options_default(wp, FALSE);
|
||||||
buffer_ensure_loaded(buf);
|
buffer_ensure_loaded(buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1556,7 +1557,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
|
|||||||
|
|
||||||
win_init_popup_win(wp, buf);
|
win_init_popup_win(wp, buf);
|
||||||
|
|
||||||
set_local_options_default(wp);
|
set_local_options_default(wp, TRUE);
|
||||||
set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
|
set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
|
||||||
(char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
|
(char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
|
||||||
set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
|
set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
void set_init_1(int clean_arg);
|
void set_init_1(int clean_arg);
|
||||||
void set_string_default(char *name, char_u *val);
|
void set_string_default(char *name, char_u *val);
|
||||||
void set_number_default(char *name, long val);
|
void set_number_default(char *name, long val);
|
||||||
void set_local_options_default(win_T *wp);
|
void set_local_options_default(win_T *wp, int do_buffer);
|
||||||
void free_all_options(void);
|
void free_all_options(void);
|
||||||
void set_init_2(void);
|
void set_init_2(void);
|
||||||
void set_init_3(void);
|
void set_init_3(void);
|
||||||
|
@ -1814,15 +1814,25 @@ func Test_popupwin_with_buffer()
|
|||||||
call writefile(['some text', 'in a buffer'], 'XsomeFile')
|
call writefile(['some text', 'in a buffer'], 'XsomeFile')
|
||||||
let buf = bufadd('XsomeFile')
|
let buf = bufadd('XsomeFile')
|
||||||
call assert_equal(0, bufloaded(buf))
|
call assert_equal(0, bufloaded(buf))
|
||||||
|
|
||||||
|
setlocal number
|
||||||
|
call setbufvar(buf, "&wrapmargin", 13)
|
||||||
|
|
||||||
let winid = popup_create(buf, {})
|
let winid = popup_create(buf, {})
|
||||||
call assert_notequal(0, winid)
|
call assert_notequal(0, winid)
|
||||||
let pos = popup_getpos(winid)
|
let pos = popup_getpos(winid)
|
||||||
call assert_equal(2, pos.height)
|
call assert_equal(2, pos.height)
|
||||||
call assert_equal(1, bufloaded(buf))
|
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 popup_close(winid)
|
||||||
call assert_equal({}, popup_getpos(winid))
|
call assert_equal({}, popup_getpos(winid))
|
||||||
call assert_equal(1, bufloaded(buf))
|
call assert_equal(1, bufloaded(buf))
|
||||||
exe 'bwipe! ' .. buf
|
exe 'bwipe! ' .. buf
|
||||||
|
setlocal nonumber
|
||||||
|
|
||||||
edit test_popupwin.vim
|
edit test_popupwin.vim
|
||||||
let winid = popup_create(bufnr(''), {})
|
let winid = popup_create(bufnr(''), {})
|
||||||
|
@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1919,
|
||||||
/**/
|
/**/
|
||||||
1918,
|
1918,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user