bunload unloads an unexpected buffer

12 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Feb 7, 2020, 10:56:43 AM2/7/20
to vim_dev
Hi all,

The :bunload command unloads an unexpected buffer when
an offset is used for the range.

For example, let us say we have four buffers (b1, b2, b3 and b4)
in the buffer list and only b1 and b2 are loaded. The buffers b3
and b4 are not loaded. The current buffer is b1. With this setup,
if the following command is executed:

.+3bunload

The expectation is that buffer b4 will be unloaded. As b4 is not
loaded, the command should not do anything. Instead of this
behavior, buffer b2 is unloaded. Basically any buffer loaded
just before the specified buffer is unloaded. I don't know whether
this is intentional or not. This is also not documented.

A similar behavior is seen when a negative offset is used.

I came across this behavior while developing a test for this.

- Yegappan

Bram Moolenaar

unread,
Feb 8, 2020, 10:01:27 AM2/8/20
to vim...@googlegroups.com, Yegappan Lakshmanan
I would expect that the number is used as-is, thus it does not matter
which buffers are loaded or not. That is consistent with other buffer
commands. Would anyone want to go to the Nth loaded buffer? That would
be quite unpredictable.

--
Latest survey shows that 3 out of 4 people make up 75% of the
world's population.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Feb 8, 2020, 1:19:09 PM2/8/20
to Bram Moolenaar, vim_dev
Hi Bram,

On Sat, Feb 8, 2020 at 7:01 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Yegappan wrote:
>
> > The :bunload command unloads an unexpected buffer when
> > an offset is used for the range.
> >
> > For example, let us say we have four buffers (b1, b2, b3 and b4)
> > in the buffer list and only b1 and b2 are loaded. The buffers b3
> > and b4 are not loaded. The current buffer is b1. With this setup,
> > if the following command is executed:
> >
> > .+3bunload
> >
> > The expectation is that buffer b4 will be unloaded. As b4 is not
> > loaded, the command should not do anything. Instead of this
> > behavior, buffer b2 is unloaded. Basically any buffer loaded
> > just before the specified buffer is unloaded. I don't know whether
> > this is intentional or not. This is also not documented.
> >
> > A similar behavior is seen when a negative offset is used.
> >
> > I came across this behavior while developing a test for this.
>
> I would expect that the number is used as-is, thus it does not matter
> which buffers are loaded or not. That is consistent with other buffer
> commands. Would anyone want to go to the Nth loaded buffer? That would
> be quite unpredictable.
>

I agree. The current behavior is unpredictable. Instead of unloading
a specified buffer, the command will unload any loaded buffer just
before or after the specified buffer if the specified buffer is not loaded.
This happens only when a range offset is used to specify the buffer.
I am not sure whether anyone relies on this behavior. I think this
should be fixed so that only the specified buffer is unloaded.

- Yegappan
Reply all
Reply to author
Forward
0 new messages