Mercurial > vim
comparison src/buffer.c @ 9485:c16e207dc465 v7.4.2023
commit https://github.com/vim/vim/commit/ea3f2e7be447a8f0c4436869620f908de5e8ef1e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 10 20:27:32 2016 +0200
patch 7.4.2023
Problem: buflist_findname_stat() may find a dummy buffer.
Solution: Set the BF_DUMMY flag after loading a dummy buffer. Start
finding buffers from the end of the list.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 10 Jul 2016 20:30:06 +0200 |
parents | 7520696c14b0 |
children | 69ed2c9d34a6 |
comparison
equal
deleted
inserted
replaced
9484:8b737122c03c | 9485:c16e207dc465 |
---|---|
2268 stat_T *stp) | 2268 stat_T *stp) |
2269 { | 2269 { |
2270 #endif | 2270 #endif |
2271 buf_T *buf; | 2271 buf_T *buf; |
2272 | 2272 |
2273 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 2273 /* Start at the last buffer, expect to find a match sooner. */ |
2274 for (buf = lastbuf; buf != NULL; buf = buf->b_prev) | |
2274 if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname | 2275 if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname |
2275 #ifdef UNIX | 2276 #ifdef UNIX |
2276 , stp | 2277 , stp |
2277 #endif | 2278 #endif |
2278 )) | 2279 )) |
2353 { | 2354 { |
2354 vim_free(pat); | 2355 vim_free(pat); |
2355 return -1; | 2356 return -1; |
2356 } | 2357 } |
2357 | 2358 |
2358 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 2359 for (buf = lastbuf; buf != NULL; buf = buf->b_prev) |
2359 if (buf->b_p_bl == find_listed | 2360 if (buf->b_p_bl == find_listed |
2360 #ifdef FEAT_DIFF | 2361 #ifdef FEAT_DIFF |
2361 && (!diffmode || diff_mode_buf(buf)) | 2362 && (!diffmode || diff_mode_buf(buf)) |
2362 #endif | 2363 #endif |
2363 && buflist_match(®match, buf, FALSE) != NULL) | 2364 && buflist_match(®match, buf, FALSE) != NULL) |
2579 { | 2580 { |
2580 buf_T *buf; | 2581 buf_T *buf; |
2581 | 2582 |
2582 if (nr == 0) | 2583 if (nr == 0) |
2583 nr = curwin->w_alt_fnum; | 2584 nr = curwin->w_alt_fnum; |
2584 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 2585 /* Assume newer buffers are used more often, start from the end. */ |
2586 for (buf = lastbuf; buf != NULL; buf = buf->b_prev) | |
2585 if (buf->b_fnum == nr) | 2587 if (buf->b_fnum == nr) |
2586 return buf; | 2588 return buf; |
2587 return NULL; | 2589 return NULL; |
2588 } | 2590 } |
2589 | 2591 |