mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 22:38:16 +00:00
vim-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".
89b693e562
This commit is contained in:
@@ -1726,7 +1726,8 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum,
|
||||
file_id_valid)) != NULL) {
|
||||
xfree(ffname);
|
||||
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) {
|
||||
// Copy the options now, if 'cpo' doesn't have 's' and not done already.
|
||||
@@ -2486,6 +2487,7 @@ buflist_nr2name(
|
||||
///
|
||||
/// @param[in,out] buf Buffer for which line and column are set.
|
||||
/// @param[in,out] win Window for which line and column are set.
|
||||
/// May be NULL when using :badd.
|
||||
/// @param[in] lnum Line number to be set. If it is zero then only
|
||||
/// options are touched.
|
||||
/// @param[in] col Column number to be set.
|
||||
@@ -2493,7 +2495,7 @@ buflist_nr2name(
|
||||
void buflist_setfpos(buf_T *const buf, win_T *const win,
|
||||
linenr_T lnum, colnr_T col,
|
||||
bool copy_options)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
wininfo_T *wip;
|
||||
|
||||
@@ -2528,7 +2530,7 @@ void buflist_setfpos(buf_T *const buf, win_T *const win,
|
||||
wip->wi_fpos.lnum = lnum;
|
||||
wip->wi_fpos.col = col;
|
||||
}
|
||||
if (copy_options) {
|
||||
if (copy_options && win != NULL) {
|
||||
// Save the window-specific option values.
|
||||
copy_winopt(&win->w_onebuf_opt, &wip->wi_opt);
|
||||
wip->wi_fold_manual = win->w_fold_manual;
|
||||
@@ -2566,29 +2568,39 @@ static bool wininfo_other_tab_diff(wininfo_T *wip)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find info for the current window in buffer "buf".
|
||||
* If not found, return the info for the most recently used window.
|
||||
* When "skip_diff_buffer" is true avoid windows with 'diff' set that is in
|
||||
* another tab page.
|
||||
* Returns NULL when there isn't any info.
|
||||
*/
|
||||
static wininfo_T *find_wininfo(buf_T *buf, int skip_diff_buffer)
|
||||
// Find info for the current window in buffer "buf".
|
||||
// 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
|
||||
// another tab page.
|
||||
// Returns NULL when there isn't any info.
|
||||
static wininfo_T *find_wininfo(buf_T *buf, bool need_options,
|
||||
bool skip_diff_buffer)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
wininfo_T *wip;
|
||||
|
||||
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
|
||||
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
|
||||
if (wip->wi_win == curwin
|
||||
&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
|
||||
)
|
||||
&& (!need_options || wip->wi_optset)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no wininfo for curwin, use the first in the list (that doesn't have
|
||||
* 'diff' set and is in another tab page). */
|
||||
// If no wininfo for curwin, use the first in the list (that doesn't have
|
||||
// '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 (skip_diff_buffer) {
|
||||
for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2607,12 +2619,10 @@ static wininfo_T *find_wininfo(buf_T *buf, int skip_diff_buffer)
|
||||
*/
|
||||
void get_winopts(buf_T *buf)
|
||||
{
|
||||
wininfo_T *wip;
|
||||
|
||||
clear_winopt(&curwin->w_onebuf_opt);
|
||||
clearFolding(curwin);
|
||||
|
||||
wip = find_wininfo(buf, true);
|
||||
wininfo_T *const wip = find_wininfo(buf, true, true);
|
||||
if (wip != NULL && wip->wi_win != curwin && wip->wi_win != NULL
|
||||
&& wip->wi_win->w_buffer == buf) {
|
||||
win_T *wp = wip->wi_win;
|
||||
@@ -2649,7 +2659,7 @@ pos_T *buflist_findfpos(buf_T *buf)
|
||||
{
|
||||
static pos_T no_position = { 1, 0, 0 };
|
||||
|
||||
wininfo_T *wip = find_wininfo(buf, false);
|
||||
wininfo_T *const wip = find_wininfo(buf, false, false);
|
||||
return (wip == NULL) ? &no_position : &(wip->wi_fpos);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user