diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-03-19 14:25:54 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-03-19 14:25:54 +0100 |
commit | 0c279bbb9c2b9fce1c837a35ace2d4644eced0b8 (patch) | |
tree | ddfa055ce2fb8b8c92623c665e660a65b90c46a4 /src | |
parent | b59494cab15310c8e2aaf59d48b270282c3e2017 (diff) | |
download | vim-git-0c279bbb9c2b9fce1c837a35ace2d4644eced0b8.tar.gz |
updated for version 7.3.869v7.3.869
Problem: bufwinnr() matches buffers in other tabs.
Solution: For bufwinnr() and ? only match buffers in the current tab.
(Alexey Radkov)
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 26 | ||||
-rw-r--r-- | src/diff.c | 2 | ||||
-rw-r--r-- | src/eval.c | 19 | ||||
-rw-r--r-- | src/ex_docmd.c | 3 | ||||
-rw-r--r-- | src/if_perl.xs | 2 | ||||
-rw-r--r-- | src/proto/buffer.pro | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 40 insertions, 16 deletions
diff --git a/src/buffer.c b/src/buffer.c index 1f460b90f..5c63899c8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -928,7 +928,8 @@ do_bufdel(command, arg, addr_count, start_bnr, end_bnr, forceit) 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, unlisted, diffmode) #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 index 864e60914..f56046095 100644 --- 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 index 7df4f7dda..49120b8c0 100644 --- 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 index d258e69e7..30fe937b5 100644 --- 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 index 67ffe18d9..f93432930 100644 --- 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 index 85aeddaef..ad205c0b3 100644 --- a/src/proto/buffer.pro +++ b/src/proto/buffer.pro @@ -17,7 +17,7 @@ int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit)); 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 index 165b8e26d..9eb46cae6 100644 --- 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, |