Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid buffer id #395

Closed
dpetka2001 opened this issue Feb 6, 2025 · 8 comments
Closed

Invalid buffer id #395

dpetka2001 opened this issue Feb 6, 2025 · 8 comments
Labels
bug Something isn't working

Comments

@dpetka2001
Copy link

Description

I use a dashboard in my Neovim configuration. Some times (not always) when I open Neovim with just nvim and the dashboard appears, if I press s to restore session (I use persistence.nvim for session management), then I get the following error

Error executing vim.schedule lua callback: ...LazyVimDev/lazy/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: ...are/LazyVimDev/lazy/vgit.nvim/lua/vgit/git/GitBuffer.lua:110: Invalid buffer id: 1
stack traceback:
	[C]: in function 'error'
	...LazyVimDev/lazy/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
	...LazyVimDev/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function <...LazyVimDev/lazy/plenary.nvim/lua/plenary/async/async.lua:44>

On the same note, I use snacks.picker as my fuzzy picker and it also uses a prompt buffer to implement its input field. I get the same error with a different buffer id there as well. I believe some kind of check should be done on which buffers vgit.nvim should attach.

In my personal opinion, a sane check would be to not try and get the bufnames of buffers that are of buftype: "prompt" and "nofile". Or maybe it could check to only try and get the bufnames from buffers that have buftype = "" (normal buffers). No idea if my assumption is actually correct and if it has some other potential side-effects. I'm sure you would know better.

  • nvim --version output: NVIM v0.11.0-dev-1698+gaa976f0d93
  • Operating system: Linux Mint 21.3
@dpetka2001 dpetka2001 added the bug Something isn't working label Feb 6, 2025
@dpetka2001
Copy link
Author

A very rough solution is the following

function GitBuffer:is_inside_git_dir()
  if vim.bo.buftype ~= '' then return end
  return git_repo.exists(self:get_name())
end

I haven't seen any side-effects locally, but this might just cover my own specific case and there might be other edge cases that I fail to think of.

@dpetka2001
Copy link
Author

Another thing I noticed is that when enabling your plugin, I cannot record macros any more. If I disable your plugin, I'm able to record macros.

I preferred to not open a separate issue for this, but if it's easier for you then I will happily create a new one.

@dpetka2001
Copy link
Author

I was wrong about the macro recording. It's because I have the following in my configuration

scene = {
          diff_preference = "unified", -- unified or split
          keymaps = {
            quit = "q",
          },
        },

But without it the windows do not close with just pressing q. Is there a way to make it a buffer-local mapping when the different previews launch?

@tanvirtin
Copy link
Owner

tanvirtin commented Feb 6, 2025

Thanks for surfacing these issues. I will target patches for them soon.

The macro thing is still an issue imo as I will try to create a solution in which this can should never happen (should should still be able to assign it to q and macros should still work, but maybe not in the VGit screens and that might be okay). I have created a separate ticket for it: #397.

@tanvirtin
Copy link
Owner

I was wrong about the macro recording. It's because I have the following in my configuration

scene = {
diff_preference = "unified", -- unified or split
keymaps = {
quit = "q",
},
},
But without it the windows do not close with just pressing q. Is there a way to make it a buffer-local mapping when the different previews launch?

The default should be <esc>, but yeah I will target buffer specific key mapping.

@dpetka2001
Copy link
Author

Yes, but that still doesn't work in my case because of the global mapping effect. I use <esc> to clear the Neovim highlights from when doing a search. I've just remapped it to <c-c> for now which I don't use in my personal configuration. But would be really helpful if the mappings were buffer-local only because there can easily be other conflicts with users' personal configurations.

@tanvirtin
Copy link
Owner

Yup I hear you, your concerns will be addressed by #397.

@dpetka2001
Copy link
Author

Thank you for your prompt response. Can confirm both issues are solved. I haven't tested extensively yet, but if I come across some other edge case, I will let you know.

Your plugin looks awesome by the way!! I hope it becomes more widespread across the Neovim community. I'm thankful I came across your Reddit post when you did 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants