chentoast / marks.nvim

A better user experience for viewing and interacting with Vim marks.
MIT License
848 stars 43 forks source link

E5108: Invalid buffer id: 1 #29

Closed TamaMcGlinn closed 2 years ago

TamaMcGlinn commented 2 years ago

I tried :MarksListAll:

but got:

E5108: Error executing lua .../marks.nvim/lua/marks/mark.lua:279: Invalid buffer id: 1

I guess you are assuming buffers that contain marks are never closed?

TamaMcGlinn commented 2 years ago

This still happens. (the error message changed to be on line 280, but is otherwise the same)

Reproduction steps: 1) Install startify.vim 2) Start neovim 3) Open a file 4) :MarksListAll

I can also confirm that :b 1 gives "E86: Buffer 1 does not exist". I think you need to actually check if the buffer exists before trying to get information about it.

When you do nvim without targeting any file, startify's buffer is buffer 1. Any files you open after that start at 2, and buffer 1 is deleted when you do so. If I open nvim somefile the bug does not reproduce because buffer 1 is somefile.

chentoast commented 2 years ago

Looks like vim-startify deletes the initial buffer by setting bufhidden=wipe, which means that it does not trigger the BufDelete autocommands set up by this plugin.

As a workaround, you can do the following:

autocmd BufLeave * if &ft == "startify" | exe "lua require'marks'._on_delete()" | endif

I can also confirm that :b 1 gives "E86: Buffer 1 does not exist".

FYI, this is just normal Vim behavior, whenever a buffer is wiped. You can check that the same behavior persists even without this plugin.

TamaMcGlinn commented 2 years ago

Thank you for the workaround.

Could you mark this issue as 'open' again so that I can be notified when the real fix gets implemented?

chentoast commented 2 years ago

I'm going to use #34 as the tracking issue for this problem.