Skip to content

Commit b866779

Browse files
author
huzilin
committed
fix bugs
1 parent 04d1abf commit b866779

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

autoload/buffet.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ function! s:GetBuffer(buffer)
351351
endfunction
352352

353353
function! buffet#bswitch(index)
354+
echom "index " . a:index
354355
let i = str2nr(a:index) - 1
355356
if i < 0 || i > len(s:buffer_ids) - 1
356357
let buffer_id = s:buffer_ids[len(s:buffer_ids)-1]
@@ -361,13 +362,14 @@ function! buffet#bswitch(index)
361362
endfunction
362363

363364
function! buffet#bnext()
364-
let next_buffer_id = (s:last_current_buffer_id+1)%len(s:buffer_ids)
365-
call buffet#bswitch(next_buffer_id)
365+
let current_buffer_id_i = index(s:buffer_ids, s:last_current_buffer_id)
366+
let next_buffer_id_i = (current_buffer_id_i+2)%len(s:buffer_ids)
367+
call buffet#bswitch(next_buffer_id_i)
366368
endfunction
367369

368370
function! buffet#bprev()
369-
let next_buffer_id = (s:last_current_buffer_id-1)
370-
call buffet#bswitch(next_buffer_id)
371+
let current_buffer_id_i = index(s:buffer_ids, s:last_current_buffer_id)
372+
call buffet#bswitch(current_buffer_id_i)
371373
endfunction
372374

373375
" inspired and based on https://vim.fandom.com/wiki/Deleting_a_buffer_without_closing_the_window

0 commit comments

Comments
 (0)