summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:15 +0000
commit6e9cd6b491267e6dff3e3f3f37d8af5f28e40672 (patch)
tree35661af16c4a0ef2a9a8e225d2d5cc82605ea289 /src/buffer.c
parentAdding upstream version 2:9.1.0496. (diff)
downloadvim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.tar.xz
vim-6e9cd6b491267e6dff3e3f3f37d8af5f28e40672.zip
Adding upstream version 2:9.1.0698.upstream/2%9.1.0698
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/buffer.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/buffer.c b/src/buffer.c
index cbec9b9..34500e4 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -50,6 +50,7 @@ static void free_buffer(buf_T *);
static void free_buffer_stuff(buf_T *buf, int free_options);
static int bt_nofileread(buf_T *buf);
static void no_write_message_buf(buf_T *buf);
+static int do_buffer_ext(int action, int start, int dir, int count, int flags);
#ifdef UNIX
# define dev_T dev_t
@@ -750,10 +751,16 @@ aucmd_abort:
*/
if (wipe_buf)
{
+ tabpage_T *tp;
+ win_T *wp;
+
// Do not wipe out the buffer if it is used in a window.
if (buf->b_nwindows > 0)
return FALSE;
+ FOR_ALL_TAB_WINDOWS(tp, wp)
+ mark_forget_file(wp, buf->b_fnum);
+
if (action == DOBUF_WIPE_REUSE)
{
// we can re-use this buffer number, store it
@@ -1100,13 +1107,30 @@ goto_buffer(
{
bufref_T old_curbuf;
int save_sea = swap_exists_action;
+ int skip_help_buf;
+
+ switch (eap->cmdidx)
+ {
+ case CMD_bnext:
+ case CMD_sbnext:
+ case CMD_bNext:
+ case CMD_bprevious:
+ case CMD_sbNext:
+ case CMD_sbprevious:
+ skip_help_buf = TRUE;
+ break;
+ default:
+ skip_help_buf = FALSE;
+ break;
+ }
set_bufref(&old_curbuf, curbuf);
if (swap_exists_action == SEA_NONE)
swap_exists_action = SEA_DIALOG;
- (void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
- start, dir, count, eap->forceit);
+ (void)do_buffer_ext(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO, start, dir, count,
+ (eap->forceit ? DOBUF_FORCEIT : 0) |
+ (skip_help_buf ? DOBUF_SKIPHELP : 0));
if (swap_exists_action == SEA_QUIT && *eap->cmd == 's')
{
#if defined(FEAT_EVAL)
@@ -1337,8 +1361,11 @@ do_buffer_ext(
if (buf == NULL)
buf = lastbuf;
}
- // don't count unlisted buffers
- if (unload || buf->b_p_bl)
+ // Don't count unlisted buffers.
+ // Avoid non-help buffers if the starting point was a non-help buffer and
+ // vice-versa.
+ if (unload || (buf->b_p_bl
+ && ((flags & DOBUF_SKIPHELP) == 0 || buf->b_help == bp->b_help)))
{
--count;
bp = NULL; // use this buffer as new starting point
@@ -1457,7 +1484,7 @@ do_buffer_ext(
// (unless it's the only window). Repeat this so long as we end up in
// a window with this buffer.
while (buf == curbuf
- && !(curwin->w_closing || curwin->w_buffer->b_locked > 0)
+ && !(win_locked(curwin) || curwin->w_buffer->b_locked > 0)
&& (!ONE_WINDOW || first_tabpage->tp_next != NULL))
{
if (win_close(curwin, FALSE) == FAIL)
@@ -5443,7 +5470,7 @@ ex_buffer_all(exarg_T *eap)
: wp->w_width != Columns)
|| (had_tab > 0 && wp != firstwin))
&& !ONE_WINDOW
- && !(wp->w_closing || wp->w_buffer->b_locked > 0)
+ && !(win_locked(wp) || wp->w_buffer->b_locked > 0)
&& !win_unlisted(wp))
{
if (win_close(wp, FALSE) == FAIL)