Mercurial > vim
comparison src/buffer.c @ 27601:cb46dd386990 v8.2.4327
patch 8.2.4327: may end up with no current buffer
Commit: https://github.com/vim/vim/commit/e3537aec2f8d6470010547af28dcbd83d41461b8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 8 15:05:20 2022 +0000
patch 8.2.4327: may end up with no current buffer
Problem: May end up with no current buffer.
Solution: When deleting the current buffer to not pick a quickfix buffer as
the new current buffer.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Feb 2022 16:15:03 +0100 |
parents | b8a5de86e9d1 |
children | ba47c7d07ce6 |
comparison
equal
deleted
inserted
replaced
27600:6e3d83368cdb | 27601:cb46dd386990 |
---|---|
1428 while (jumpidx != curwin->w_jumplistidx) | 1428 while (jumpidx != curwin->w_jumplistidx) |
1429 { | 1429 { |
1430 buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum); | 1430 buf = buflist_findnr(curwin->w_jumplist[jumpidx].fmark.fnum); |
1431 if (buf != NULL) | 1431 if (buf != NULL) |
1432 { | 1432 { |
1433 if (buf == curbuf || !buf->b_p_bl) | 1433 // Skip current and unlisted bufs. Also skip a quickfix |
1434 buf = NULL; // skip current and unlisted bufs | 1434 // buffer, it might be deleted soon. |
1435 if (buf == curbuf || !buf->b_p_bl | |
1436 #if defined(FEAT_QUICKFIX) | |
1437 || bt_quickfix(buf) | |
1438 #endif | |
1439 ) | |
1440 buf = NULL; | |
1435 else if (buf->b_ml.ml_mfp == NULL) | 1441 else if (buf->b_ml.ml_mfp == NULL) |
1436 { | 1442 { |
1437 // skip unloaded buf, but may keep it for later | 1443 // skip unloaded buf, but may keep it for later |
1438 if (bp == NULL) | 1444 if (bp == NULL) |
1439 bp = buf; | 1445 bp = buf; |
1465 buf = curbuf->b_prev; | 1471 buf = curbuf->b_prev; |
1466 forward = FALSE; | 1472 forward = FALSE; |
1467 continue; | 1473 continue; |
1468 } | 1474 } |
1469 // in non-help buffer, try to skip help buffers, and vv | 1475 // in non-help buffer, try to skip help buffers, and vv |
1470 if (buf->b_help == curbuf->b_help && buf->b_p_bl) | 1476 if (buf->b_help == curbuf->b_help && buf->b_p_bl |
1477 #if defined(FEAT_QUICKFIX) | |
1478 && !bt_quickfix(buf) | |
1479 #endif | |
1480 ) | |
1471 { | 1481 { |
1472 if (buf->b_ml.ml_mfp != NULL) // found loaded buffer | 1482 if (buf->b_ml.ml_mfp != NULL) // found loaded buffer |
1473 break; | 1483 break; |
1474 if (bp == NULL) // remember unloaded buf for later | 1484 if (bp == NULL) // remember unloaded buf for later |
1475 bp = buf; | 1485 bp = buf; |
1483 if (buf == NULL) // No loaded buffer, use unloaded one | 1493 if (buf == NULL) // No loaded buffer, use unloaded one |
1484 buf = bp; | 1494 buf = bp; |
1485 if (buf == NULL) // No loaded buffer, find listed one | 1495 if (buf == NULL) // No loaded buffer, find listed one |
1486 { | 1496 { |
1487 FOR_ALL_BUFFERS(buf) | 1497 FOR_ALL_BUFFERS(buf) |
1488 if (buf->b_p_bl && buf != curbuf) | 1498 if (buf->b_p_bl && buf != curbuf |
1499 #if defined(FEAT_QUICKFIX) | |
1500 && !bt_quickfix(buf) | |
1501 #endif | |
1502 ) | |
1489 break; | 1503 break; |
1490 } | 1504 } |
1491 if (buf == NULL) // Still no buffer, just take one | 1505 if (buf == NULL) // Still no buffer, just take one |
1492 { | 1506 { |
1493 if (curbuf->b_next != NULL) | 1507 if (curbuf->b_next != NULL) |
1494 buf = curbuf->b_next; | 1508 buf = curbuf->b_next; |
1495 else | 1509 else |
1496 buf = curbuf->b_prev; | 1510 buf = curbuf->b_prev; |
1511 #if defined(FEAT_QUICKFIX) | |
1512 if (bt_quickfix(buf)) | |
1513 buf = NULL; | |
1514 #endif | |
1497 } | 1515 } |
1498 } | 1516 } |
1499 | 1517 |
1500 if (buf == NULL) | 1518 if (buf == NULL) |
1501 { | 1519 { |