fix(bufkill): wrap around correctly (#3461)

This commit is contained in:
LostNeophyte 2022-11-14 11:44:53 +01:00 committed by GitHub
parent dd54887bba
commit ae89f07377
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -220,7 +220,7 @@ function M.buf_kill(kill_command, bufnr, force)
if #buffers > 1 and #windows > 0 then
for i, v in ipairs(buffers) do
if v == bufnr then
local prev_buf_idx = i == 1 and (#buffers - 1) or (i - 1)
local prev_buf_idx = i == 1 and #buffers or (i - 1)
local prev_buffer = buffers[prev_buf_idx]
for _, win in ipairs(windows) do
api.nvim_win_set_buf(win, prev_buffer)