barbar.nvim icon indicating copy to clipboard operation
barbar.nvim copied to clipboard

Buffer tabs appear in reverse order when opening multiple files with Neovim

Open mawkler opened this issue 3 years ago • 19 comments

For instance, when running nvim foo bar baz in the shell, the buffer tabs order, i.e. baz, bar, foo.

mawkler avatar Oct 31 '20 21:10 mawkler

@romgrk I noticed today that buffers still appear in reverse order when sourcing a saved session.

To reproduce:

" init.vim
call plug#begin('~/.vim/bundle')
Plug 'romgrk/barbar.nvim'
call plug#end()
  1. > nvim foo bar
  2. :mksession test.vim | qa
  3. > nvim
  4. :source test.vim
  5. Buffer tabs appear in reverse order: bar, foo

mawkler avatar Nov 06 '20 20:11 mawkler

Done

romgrk avatar Nov 07 '20 10:11 romgrk

@romgrk 3c9493e doesn't seem to solve the issue. I tried out the latest version of barbar.nvim today but the procedure mentioned in my previous comment still makes the buffer tabs appear in reverse order 🤔

mawkler avatar Nov 10 '20 10:11 mawkler

Can't reproduce. I'll need more details.

romgrk avatar Nov 10 '20 11:11 romgrk

I just updated barbar.nvim to the latest commit 10df6f7.

:version outputs the following:

NVIM v0.5.0-812-gd17e50879
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-317a2489-aba5-414a-b9f3-9551746c326c

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

The steps I used to reproduce the error:

" init.vim
call plug#begin('~/.vim/bundle')
Plug 'romgrk/barbar.nvim'
call plug#end()
  1. > nvim foo bar
  2. :mksession! test.vim | qa
  3. > nvim
  4. :source test.vim
  5. Buffer tabs appear in reverse order: bar, foo

mawkler avatar Nov 10 '20 12:11 mawkler

Still can't reproduce on my setup. I'll keep the issue open and might give it another look eventually but I have too much work to tell when I'll be able to get back to this. PR welcome if you want to try to fix it.

romgrk avatar Nov 10 '20 13:11 romgrk

@romgrk Btw, I noticed that when reproducing the steps above, but doing nvim -c 'source test.vim' instead of steps 3 and 4 doesn't cause the bug. The buffer tabs only appear in reverse order when editing the buffers from inside of neovim.

Also I'm getting the exact same issue on my Windows machine using the minimal init.vim above and so it's odd that you can't reproduce the bug 🤔

mawkler avatar Nov 15 '20 21:11 mawkler

@romgrk Below is the session file that Neovim generates after I run :mksession. Perhaps the reason you're not seeing the same bug may be since you get a different session file on :mksession? Could you try reproducing the bug using this session file please?

let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
cd ~/
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +1 foo
badd +0 bar
argglobal
%argdel
edit bar
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 21) / 42)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabnext 1
if exists('s:wipebuf') && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 winminheight=1 winminwidth=1 shortmess=filnxtToOF
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

mawkler avatar Nov 21 '20 20:11 mawkler

Can't reproduce, I get "foo, bar".

romgrk avatar Nov 21 '20 21:11 romgrk

That's really odd that you can't reproduce it. What version of Neovim are you using?

mawkler avatar Nov 21 '20 21:11 mawkler

v0.5.0-845-gd79335c49, very recent build

romgrk avatar Nov 21 '20 22:11 romgrk

Any update on this thread? I came across this as well

SalTor avatar Apr 06 '21 15:04 SalTor

Still in my task list but I don't have enough bandwidth these days, and if I can't reproduce I can't debug. If anyone is interested in debugging further I can explain where to look.

romgrk avatar Apr 06 '21 16:04 romgrk

The the interim I've just remapped my buffer navigation to be backwards 😆

SalTor avatar Apr 06 '21 19:04 SalTor

I take that back, that solution doesn't always work because it seems barbar is sorting my buffers 😵 💫

SalTor avatar Apr 06 '21 19:04 SalTor

Also it seems to me like Ctrl-i and Ctrl-o navigation has been wonky since installing barbar 🤔

SalTor avatar Apr 06 '21 20:04 SalTor

File a different issue for the ctrl-i/ctrl-o thing if you have more details.

romgrk avatar Apr 07 '21 06:04 romgrk

@melkster does this still happen?

Iron-E avatar May 27 '22 21:05 Iron-E

@Iron-E Yes 😕

mawkler avatar May 27 '22 22:05 mawkler