8000 Invalid buffer id-errors · Issue #266 · goolord/alpha-nvim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Invalid buffer id-errors #266
Open
Open
@LiveNL

Description

@LiveNL

Hi,

From time to time I experience 'Invalid buffer id' errors. So far, it is unclear why and how these are deterministically being triggered, and therefore I'm also unsure how to provide a path to replicate the error.

Below you can find a screenshot of error.

Screenshot 2024-02-24 at 20 29 27

As a suggestion, I'm experimenting with the following change in my code locally (creating branches is forbidden):

--- a/lua/alpha.lua
+++ b/lua/alpha.lua
@@ -618,6 +618,12 @@ function alpha.draw(conf, state)
     -- when the screen is cleared and then redrawn
     -- so we save the index before that happens
     local ix = cursor_ix
+
+    -- Check if the buffer is valid before proceeding
+    if not vim.api.nvim_buf_is_valid(state.buffer) then
+        return
+    end
+
     vim.api.nvim_buf_set_option(state.buffer, "modifiable", true)
     vim.api.nvim_buf_clear_namespace(state.buffer, -1, 0, -1)
     vim.api.nvim_buf_set_lines(state.buffer, 0, -1, false, {})
     
@@ -630,7 +630,10 @@ function alpha.draw(conf, state)
     layout(conf, state)
     vim.api.nvim_buf_set_option(state.buffer, "modifiable", false)
     local active_win = active_window(state)
-    if vim.api.nvim_get_current_win() == active_win then
+    local active_win_is_valid = active_win and vim.api.nvim_win_is_valid(active_win)
+    local active_win_is_current = active_win == vim.api.nvim_get_current_win()
+
+    if active_win_is_valid and active_win_is_current then
         if #cursor_jumps ~= 0 then
             -- TODO: this is pcalled because a bunch of window events
             -- like WinEnter will say 'alpha' is the current open buffer

In file: https://github.com/goolord/alpha-nvim/blob/main/lua/alpha.lua

I'm happy to hear any suggestions!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0