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

fix(pinned): buffer does not exist after switching sessions

Open zkygr opened this issue 1 year ago • 0 comments

Hello,

I've been experimenting with pinned buffers and sessions, and I encountered an error.

Steps to reproduce:

  • Pin a buffer
  • Restore a Vim session
  • Pin another buffer

Error Message:

Error executing Lua callback: ...hare/nvim/lazy/bufferline.nvim/lua/bufferline/groups.lua:154: Invalid buffer id: 3
stack traceback:
        [C]: in function 'nvim_buf_get_name'
        ...hare/nvim/lazy/bufferline.nvim/lua/bufferline/groups.lua:154: in function 'persist_pinned_buffers'
        ...hare/nvim/lazy/bufferline.nvim/lua/bufferline/groups.lua:323: in function 'add_element'
        ...hare/nvim/lazy/bufferline.nvim/lua/bufferline/groups.lua:486: in function 'toggle_pin'
        ...local/share/nvim/lazy/bufferline.nvim/lua/bufferline.lua:172: in function <...local/share/nvim/lazy/bufferline.nvim/lua/bufferline.lua:172>

Video:

bufferline_error.webm


I believe a possible solution could be updating the buffer IDs, but I wanted to get another opinion before spending more time on it. My current fix only suppresses the error messages, but the incorrect buffer IDs are still in memory. Perhaps I'm overlooking something.

zkygr avatar Sep 15 '24 15:09 zkygr