Mercurial > vim
comparison src/buffer.c @ 4236:23ce9a61bdc2 v7.3.869
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 19 Mar 2013 14:25:54 +0100 |
parents | 2f7883063b19 |
children | edd0bc1f26bd |
comparison
equal
deleted
inserted
replaced
4235:acfd8c31da18 | 4236:23ce9a61bdc2 |
---|---|
926 if (*arg == NUL) | 926 if (*arg == NUL) |
927 break; | 927 break; |
928 if (!VIM_ISDIGIT(*arg)) | 928 if (!VIM_ISDIGIT(*arg)) |
929 { | 929 { |
930 p = skiptowhite_esc(arg); | 930 p = skiptowhite_esc(arg); |
931 bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, FALSE); | 931 bnr = buflist_findpat(arg, p, command == DOBUF_WIPE, |
932 FALSE, FALSE); | |
932 if (bnr < 0) /* failed */ | 933 if (bnr < 0) /* failed */ |
933 break; | 934 break; |
934 arg = p; | 935 arg = p; |
935 } | 936 } |
936 else | 937 else |
2127 )) | 2128 )) |
2128 return buf; | 2129 return buf; |
2129 return NULL; | 2130 return NULL; |
2130 } | 2131 } |
2131 | 2132 |
2132 #if defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL) || defined(PROTO) | 2133 #if defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL) \ |
2134 || defined(PROTO) | |
2133 /* | 2135 /* |
2134 * Find file in buffer list by a regexp pattern. | 2136 * Find file in buffer list by a regexp pattern. |
2135 * Return fnum of the found buffer. | 2137 * Return fnum of the found buffer. |
2136 * Return < 0 for error. | 2138 * Return < 0 for error. |
2137 */ | 2139 */ |
2138 int | 2140 int |
2139 buflist_findpat(pattern, pattern_end, unlisted, diffmode) | 2141 buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only) |
2140 char_u *pattern; | 2142 char_u *pattern; |
2141 char_u *pattern_end; /* pointer to first char after pattern */ | 2143 char_u *pattern_end; /* pointer to first char after pattern */ |
2142 int unlisted; /* find unlisted buffers */ | 2144 int unlisted; /* find unlisted buffers */ |
2143 int diffmode UNUSED; /* find diff-mode buffers only */ | 2145 int diffmode UNUSED; /* find diff-mode buffers only */ |
2146 int curtab_only; /* find buffers in current tab only */ | |
2144 { | 2147 { |
2145 buf_T *buf; | 2148 buf_T *buf; |
2146 regprog_T *prog; | 2149 regprog_T *prog; |
2147 int match = -1; | 2150 int match = -1; |
2148 int find_listed; | 2151 int find_listed; |
2206 #ifdef FEAT_DIFF | 2209 #ifdef FEAT_DIFF |
2207 && (!diffmode || diff_mode_buf(buf)) | 2210 && (!diffmode || diff_mode_buf(buf)) |
2208 #endif | 2211 #endif |
2209 && buflist_match(prog, buf) != NULL) | 2212 && buflist_match(prog, buf) != NULL) |
2210 { | 2213 { |
2214 if (curtab_only) | |
2215 { | |
2216 /* Ignore the match if the buffer is not open in | |
2217 * the current tab. */ | |
2218 #ifdef FEAT_WINDOWS | |
2219 win_T *wp; | |
2220 | |
2221 for (wp = firstwin; wp != NULL; wp = wp->w_next) | |
2222 if (wp->w_buffer == buf) | |
2223 break; | |
2224 if (wp == NULL) | |
2225 continue; | |
2226 #else | |
2227 if (curwin->w_buffer != buf) | |
2228 continue; | |
2229 #endif | |
2230 } | |
2211 if (match >= 0) /* already found a match */ | 2231 if (match >= 0) /* already found a match */ |
2212 { | 2232 { |
2213 match = -2; | 2233 match = -2; |
2214 break; | 2234 break; |
2215 } | 2235 } |