1
0
forked from aniani/vim

patch 9.1.0554: :bw leaves jumplist and tagstack data around

Problem:  :bw leaves jumplist and tagstack data around
          (Paul "Joey" Clark)
Solution: Wipe jumplist and tagstack references to the wiped buffer
          (LemonBoy)

As documented the :bwipeout command brutally deletes all the references
to the buffer, so let's make it delete all the entries in the jump list
and tag stack referring to the wiped-out buffer.

fixes: #8201
closes: #15185

Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
LemonBoy
2024-07-09 20:03:24 +02:00
committed by Christian Brabandt
parent d33a518025
commit 4ff3a9b1e3
11 changed files with 72 additions and 20 deletions

View File

@@ -129,6 +129,40 @@ setmark_pos(int c, pos_T *pos, int fnum)
return FAIL;
}
/*
* Delete every entry referring to file 'fnum' from both the jumplist and the
* tag stack.
*/
void
mark_forget_file(win_T *wp, int fnum)
{
int i;
for (i = 0; i < wp->w_jumplistlen; ++i)
if (wp->w_jumplist[i].fmark.fnum == fnum)
{
vim_free(wp->w_jumplist[i].fname);
mch_memmove(&wp->w_jumplist[i], &wp->w_jumplist[i + 1],
(wp->w_jumplistlen - i - 1) * sizeof(xfmark_T));
if (wp->w_jumplistidx > i)
--wp->w_jumplistidx;
--wp->w_jumplistlen;
--i;
}
for (i = 0; i < wp->w_tagstacklen; i++)
if (wp->w_tagstack[i].fmark.fnum == fnum)
{
tagstack_clear_entry(&wp->w_tagstack[i]);
mch_memmove(&wp->w_tagstack[i], &wp->w_tagstack[i + 1],
(wp->w_tagstacklen - i - 1) * sizeof(taggy_T));
if (wp->w_tagstackidx > i)
--wp->w_tagstackidx;
--wp->w_tagstacklen;
--i;
}
}
/*
* Set the previous context mark to the current position and add it to the
* jump list.