# HG changeset patch # User Bram Moolenaar # Date 1363699554 -3600 # Node ID 23ce9a61bdc2a35892ec4e4fa22e8964d60dc6cd # Parent acfd8c31da183f849a757e1d0df8918de3d38df1 updated for version 7.3.869 Problem: bufwinnr() matches buffers in other tabs. Solution: For bufwinnr() and ? only match buffers in the current tab. (Alexey Radkov) diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -928,7 +928,8 @@ do_bufdel(command, arg, addr_count, star if (!VIM_ISDIGIT(*arg)) { p = skiptowhite_esc(arg); - bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, FALSE); + bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, + FALSE, FALSE); if (bnr < 0) /* failed */ break; arg = p; @@ -2129,18 +2130,20 @@ buflist_findname_stat(ffname, stp) return NULL; } -#if defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL) || defined(PROTO) +#if defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL) \ + || defined(PROTO) /* * Find file in buffer list by a regexp pattern. * Return fnum of the found buffer. * Return < 0 for error. */ int -buflist_findpat(pattern, pattern_end, unlisted, diffmode) +buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only) char_u *pattern; char_u *pattern_end; /* pointer to first char after pattern */ int unlisted; /* find unlisted buffers */ int diffmode UNUSED; /* find diff-mode buffers only */ + int curtab_only; /* find buffers in current tab only */ { buf_T *buf; regprog_T *prog; @@ -2208,6 +2211,23 @@ buflist_findpat(pattern, pattern_end, un #endif && buflist_match(prog, buf) != NULL) { + if (curtab_only) + { + /* Ignore the match if the buffer is not open in + * the current tab. */ +#ifdef FEAT_WINDOWS + win_T *wp; + + for (wp = firstwin; wp != NULL; wp = wp->w_next) + if (wp->w_buffer == buf) + break; + if (wp == NULL) + continue; +#else + if (curwin->w_buffer != buf) + continue; +#endif + } if (match >= 0) /* already found a match */ { match = -2; diff --git a/src/diff.c b/src/diff.c --- a/src/diff.c +++ b/src/diff.c @@ -2152,7 +2152,7 @@ ex_diffgetput(eap) i = atol((char *)eap->arg); else { - i = buflist_findpat(eap->arg, p, FALSE, TRUE); + i = buflist_findpat(eap->arg, p, FALSE, TRUE, FALSE); if (i < 0) return; /* error message already given */ } diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -9019,14 +9019,15 @@ f_bufloaded(argvars, rettv) rettv->vval.v_number = (buf != NULL && buf->b_ml.ml_mfp != NULL); } -static buf_T *get_buf_tv __ARGS((typval_T *tv)); +static buf_T *get_buf_tv __ARGS((typval_T *tv, int curtab_only)); /* * Get buffer by number or pattern. */ static buf_T * -get_buf_tv(tv) +get_buf_tv(tv, curtab_only) typval_T *tv; + int curtab_only; { char_u *name = tv->vval.v_string; int save_magic; @@ -9049,7 +9050,7 @@ get_buf_tv(tv) p_cpo = (char_u *)""; buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), - TRUE, FALSE)); + TRUE, FALSE, curtab_only)); p_magic = save_magic; p_cpo = save_cpo; @@ -9073,7 +9074,7 @@ f_bufname(argvars, rettv) (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ ++emsg_off; - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], FALSE); rettv->v_type = VAR_STRING; if (buf != NULL && buf->b_fname != NULL) rettv->vval.v_string = vim_strsave(buf->b_fname); @@ -9096,7 +9097,7 @@ f_bufnr(argvars, rettv) (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ ++emsg_off; - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], FALSE); --emsg_off; /* If the buffer isn't found and the second argument is not zero create a @@ -9131,7 +9132,7 @@ f_bufwinnr(argvars, rettv) (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ ++emsg_off; - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], TRUE); #ifdef FEAT_WINDOWS for (wp = firstwin; wp; wp = wp->w_next) { @@ -11095,7 +11096,7 @@ f_getbufline(argvars, rettv) (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ ++emsg_off; - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], FALSE); --emsg_off; lnum = get_tv_lnum_buf(&argvars[1], buf); @@ -11123,7 +11124,7 @@ f_getbufvar(argvars, rettv) (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ varname = get_tv_string_chk(&argvars[1]); ++emsg_off; - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], FALSE); if (argvars[2].v_type != VAR_UNKNOWN) /* set the default value */ @@ -16216,7 +16217,7 @@ f_setbufvar(argvars, rettv) return; (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ varname = get_tv_string_chk(&argvars[1]); - buf = get_buf_tv(&argvars[0]); + buf = get_buf_tv(&argvars[0], FALSE); varp = &argvars[2]; if (buf != NULL && varname != NULL && varp != NULL) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -2645,7 +2645,8 @@ do_one_cmd(cmdlinep, sourcing, while (p > ea.arg && vim_iswhite(p[-1])) --p; } - ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & BUFUNL) != 0, FALSE); + ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & BUFUNL) != 0, + FALSE, FALSE); if (ea.line2 < 0) /* failed */ goto doend; ea.addr_count = 1; diff --git a/src/if_perl.xs b/src/if_perl.xs --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -1056,7 +1056,7 @@ Buffers(...) pat = (char_u *)SvPV(sv, len); ++emsg_off; - b = buflist_findpat(pat, pat+len, FALSE, FALSE); + b = buflist_findpat(pat, pat+len, FALSE, FALSE, FALSE); --emsg_off; } diff --git a/src/proto/buffer.pro b/src/proto/buffer.pro --- a/src/proto/buffer.pro +++ b/src/proto/buffer.pro @@ -17,7 +17,7 @@ int buflist_getfile __ARGS((int n, linen void buflist_getfpos __ARGS((void)); buf_T *buflist_findname_exp __ARGS((char_u *fname)); buf_T *buflist_findname __ARGS((char_u *ffname)); -int buflist_findpat __ARGS((char_u *pattern, char_u *pattern_end, int unlisted, int diffmode)); +int buflist_findpat __ARGS((char_u *pattern, char_u *pattern_end, int unlisted, int diffmode, int curtab_only)); int ExpandBufnames __ARGS((char_u *pat, int *num_file, char_u ***file, int options)); buf_T *buflist_findnr __ARGS((int nr)); char_u *buflist_nr2name __ARGS((int n, int fullname, int helptail)); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 869, +/**/ 868, /**/ 867,