harpoon icon indicating copy to clipboard operation
harpoon copied to clipboard

Using list():select() re-creates a buffer when already existing buffer uses absolute path

Open sug44 opened this issue 10 months ago • 0 comments

Bug happens when using list():select() on a file in the buffer with the buffer path saved as absolute(or any way other than relative to the current working directory) because vim.fn.bufnr(to_exact_name(list_item.value)) returns -1. This is most noticeable when you lose cursor position every time you use list():select().

https://github.com/neovim/neovim/issues/3764 describes how sometimes buffer path is saved as absolute, but its a complete mystery for me.

Steps to reproduce:

  1. Open a file and get its buffer path saved as absolute(see the link above).
  2. Do :buffers to confirm its absolute(or any way other than relative to the current working directory)
  3. Set the cursor position to the second line
  4. list():select() the file
  5. Observe how the cursor position gets reset to the first line

sug44 avatar Apr 08 '24 08:04 sug44