mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1904: still using default option values after using ":badd +1"
Problem: Still using default option values after using ":badd +1". Solution: Find a window where options were set. Don't set the window when using ":badd".
This commit is contained in:
24
src/buffer.c
24
src/buffer.c
@@ -1974,7 +1974,8 @@ buflist_new(
|
|||||||
{
|
{
|
||||||
vim_free(ffname);
|
vim_free(ffname);
|
||||||
if (lnum != 0)
|
if (lnum != 0)
|
||||||
buflist_setfpos(buf, curwin, lnum, (colnr_T)0, FALSE);
|
buflist_setfpos(buf, (flags & BLN_NOCURWIN) ? NULL : curwin,
|
||||||
|
lnum, (colnr_T)0, FALSE);
|
||||||
|
|
||||||
if ((flags & BLN_NOOPT) == 0)
|
if ((flags & BLN_NOOPT) == 0)
|
||||||
// copy the options now, if 'cpo' doesn't have 's' and not done
|
// copy the options now, if 'cpo' doesn't have 's' and not done
|
||||||
@@ -2908,7 +2909,7 @@ buflist_nr2name(
|
|||||||
void
|
void
|
||||||
buflist_setfpos(
|
buflist_setfpos(
|
||||||
buf_T *buf,
|
buf_T *buf,
|
||||||
win_T *win,
|
win_T *win, // may be NULL when using :badd
|
||||||
linenr_T lnum,
|
linenr_T lnum,
|
||||||
colnr_T col,
|
colnr_T col,
|
||||||
int copy_options)
|
int copy_options)
|
||||||
@@ -2950,7 +2951,7 @@ buflist_setfpos(
|
|||||||
wip->wi_fpos.lnum = lnum;
|
wip->wi_fpos.lnum = lnum;
|
||||||
wip->wi_fpos.col = col;
|
wip->wi_fpos.col = col;
|
||||||
}
|
}
|
||||||
if (copy_options)
|
if (copy_options && win != NULL)
|
||||||
{
|
{
|
||||||
// Save the window-specific option values.
|
// Save the window-specific option values.
|
||||||
copy_winopt(&win->w_onebuf_opt, &wip->wi_opt);
|
copy_winopt(&win->w_onebuf_opt, &wip->wi_opt);
|
||||||
@@ -2997,6 +2998,7 @@ wininfo_other_tab_diff(wininfo_T *wip)
|
|||||||
/*
|
/*
|
||||||
* Find info for the current window in buffer "buf".
|
* Find info for the current window in buffer "buf".
|
||||||
* If not found, return the info for the most recently used window.
|
* If not found, return the info for the most recently used window.
|
||||||
|
* When "need_options" is TRUE skip entries where wi_optset is FALSE.
|
||||||
* When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in
|
* When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in
|
||||||
* another tab page.
|
* another tab page.
|
||||||
* Returns NULL when there isn't any info.
|
* Returns NULL when there isn't any info.
|
||||||
@@ -3004,6 +3006,7 @@ wininfo_other_tab_diff(wininfo_T *wip)
|
|||||||
static wininfo_T *
|
static wininfo_T *
|
||||||
find_wininfo(
|
find_wininfo(
|
||||||
buf_T *buf,
|
buf_T *buf,
|
||||||
|
int need_options,
|
||||||
int skip_diff_buffer UNUSED)
|
int skip_diff_buffer UNUSED)
|
||||||
{
|
{
|
||||||
wininfo_T *wip;
|
wininfo_T *wip;
|
||||||
@@ -3013,18 +3016,25 @@ find_wininfo(
|
|||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
|
&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
|
||||||
#endif
|
#endif
|
||||||
)
|
|
||||||
|
&& (!need_options || wip->wi_optset))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// If no wininfo for curwin, use the first in the list (that doesn't have
|
// If no wininfo for curwin, use the first in the list (that doesn't have
|
||||||
// 'diff' set and is in another tab page).
|
// 'diff' set and is in another tab page).
|
||||||
|
// If "need_options" is TRUE skip entries that don't have options set,
|
||||||
|
// unless the window is editing "buf", so we can copy from the window
|
||||||
|
// itself.
|
||||||
if (wip == NULL)
|
if (wip == NULL)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (skip_diff_buffer)
|
if (skip_diff_buffer)
|
||||||
{
|
{
|
||||||
FOR_ALL_BUF_WININFO(buf, wip)
|
FOR_ALL_BUF_WININFO(buf, wip)
|
||||||
if (!wininfo_other_tab_diff(wip))
|
if (!wininfo_other_tab_diff(wip)
|
||||||
|
&& (!need_options || wip->wi_optset
|
||||||
|
|| (wip->wi_win != NULL
|
||||||
|
&& wip->wi_win->w_buffer == buf)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3050,7 +3060,7 @@ get_winopts(buf_T *buf)
|
|||||||
clearFolding(curwin);
|
clearFolding(curwin);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wip = find_wininfo(buf, TRUE);
|
wip = find_wininfo(buf, TRUE, TRUE);
|
||||||
if (wip != NULL && wip->wi_win != NULL
|
if (wip != NULL && wip->wi_win != NULL
|
||||||
&& wip->wi_win != curwin && wip->wi_win->w_buffer == buf)
|
&& wip->wi_win != curwin && wip->wi_win->w_buffer == buf)
|
||||||
{
|
{
|
||||||
@@ -3097,7 +3107,7 @@ buflist_findfpos(buf_T *buf)
|
|||||||
wininfo_T *wip;
|
wininfo_T *wip;
|
||||||
static pos_T no_position = {1, 0, 0};
|
static pos_T no_position = {1, 0, 0};
|
||||||
|
|
||||||
wip = find_wininfo(buf, FALSE);
|
wip = find_wininfo(buf, FALSE, FALSE);
|
||||||
if (wip != NULL)
|
if (wip != NULL)
|
||||||
return &(wip->wi_fpos);
|
return &(wip->wi_fpos);
|
||||||
else
|
else
|
||||||
|
@@ -2640,7 +2640,10 @@ do_ecmd(
|
|||||||
if (tlnum <= 0)
|
if (tlnum <= 0)
|
||||||
tlnum = 1L;
|
tlnum = 1L;
|
||||||
}
|
}
|
||||||
(void)buflist_new(ffname, sfname, tlnum, BLN_LISTED);
|
// Add BLN_NOCURWIN to avoid a new wininfo items is assocated
|
||||||
|
// with the current window.
|
||||||
|
(void)buflist_new(ffname, sfname, tlnum,
|
||||||
|
BLN_LISTED | BLN_NOCURWIN);
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
buf = buflist_new(ffname, sfname, 0L,
|
buf = buflist_new(ffname, sfname, 0L,
|
||||||
|
@@ -366,7 +366,7 @@ func Test_badd_options()
|
|||||||
new SomeNewBuffer
|
new SomeNewBuffer
|
||||||
setlocal numberwidth=3
|
setlocal numberwidth=3
|
||||||
wincmd p
|
wincmd p
|
||||||
badd SomeNewBuffer
|
badd +1 SomeNewBuffer
|
||||||
new SomeNewBuffer
|
new SomeNewBuffer
|
||||||
call assert_equal(3, &numberwidth)
|
call assert_equal(3, &numberwidth)
|
||||||
close
|
close
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
1904,
|
||||||
/**/
|
/**/
|
||||||
1903,
|
1903,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -931,6 +931,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
|
|||||||
#define BLN_NOOPT 16 // don't copy options to existing buffer
|
#define BLN_NOOPT 16 // don't copy options to existing buffer
|
||||||
#define BLN_DUMMY_OK 32 // also find an existing dummy buffer
|
#define BLN_DUMMY_OK 32 // also find an existing dummy buffer
|
||||||
#define BLN_REUSE 64 // may re-use number from buf_reuse
|
#define BLN_REUSE 64 // may re-use number from buf_reuse
|
||||||
|
#define BLN_NOCURWIN 128 // buffer is not associated with curwin
|
||||||
|
|
||||||
// Values for in_cinkeys()
|
// Values for in_cinkeys()
|
||||||
#define KEY_OPEN_FORW 0x101
|
#define KEY_OPEN_FORW 0x101
|
||||||
|
Reference in New Issue
Block a user