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

bug: Invalid Window id Error #400

Closed
3 tasks done
tummetott opened this issue Mar 29, 2024 · 3 comments · Fixed by #437
Closed
3 tasks done

bug: Invalid Window id Error #400

tummetott opened this issue Mar 29, 2024 · 3 comments · Fixed by #437
Labels
bug Something isn't working

Comments

@tummetott
Copy link

Did you check docs and existing issues?

  • I have read all the edgy.nvim docs
  • I have searched the existing issues of edgy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.5 Build type: Release LuaJIT 2.1.1703358377

Operating system/version

MacOs 14.2.1

Describe the bug

I get a invalid window id error:

Error setting option `foldlevel=99`

OptionSet Autocommands for "foldlevel": Vim(append):Error executing lua callback: ...es/.repro/plugins/trouble.nvim/lua/trouble/view/init.lua:150: Invalid window id: 1002
stack traceback:
^I[C]: in function '__index'
^I...es/.repro/plugins/trouble.nvim/lua/trouble/view/init.lua:150: in function <...es/.repro/plugins/trouble.nvim/lua/trouble/view/init.lua:145>
^I[C]: at 0x0104bb94c0
^I[C]: in function 'pcall'
^I.../.repro/plugins/trouble.nvim/lua/trouble/view/window.lua:177: in function 'set_options'
^I.../.repro/plugins/trouble.nvim/lua/trouble/view/window.lua:199: in function 'mount'
^I.../.repro/plugins/trouble.nvim/lua/trouble/view/window.lua:249: in function 'open'
^I...es/.repro/plugins/trouble.nvim/lua/trouble/view/init.lua:385: in function 'open'
^I...s/issues/.repro/plugins/trouble.nvim/lua/trouble/api.lua:55: in function <...s/issues/.repro/plugins/trouble.nvim/lua/trouble/api.lua:45>
^I...sues/.repro/plugins/trouble.nvim/lua/trouble/command.lua:130: in function 'execute'
^I.../.repro/plugins/trouble.nvim/lua/trouble/config/init.lua:179: in function <.../.repro/plugins/trouble.nvim/lua/trouble/config/init.lua:178>

Steps To Reproduce

nvim -u repro.lua
:Trouble quickfix Open a emtpy trouble window. it can also be diagnostics or whatever, it does not matter
:lua require('edgy').close() Close the Edgy Window
:Trouble quickfix Open trouble again

BTW: the same error occurs in several scenarios, this is just one reproduction

Expected Behavior

No Error

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    {
        "folke/trouble.nvim",
        branch = "dev",
        lazy = false,
        opts = {
            follow = false,
            restore = true,
            auto_preview = false,
            auto_refresh = false,
        },
    },
    {
        'folke/edgy.nvim',
        opts = {
            bottom = {
                {
                    title = 'TROUBLE',
                    ft = 'trouble',
                },
            }
        }

    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/edgy.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@tummetott tummetott added the bug Something isn't working label Mar 29, 2024
@folke folke transferred this issue from folke/edgy.nvim Mar 29, 2024
@folke
Copy link
Owner

folke commented Mar 29, 2024

This is now fixed in Trouble v3.
Thank you for reporting!

@folke folke closed this as completed Mar 29, 2024
@tummetott
Copy link
Author

Awesome, took you 11 minutes, you're a machine 😄

I thought it's an edgy error, thanks for fixing

@amtoine
Copy link

amtoine commented May 20, 2024

i get a very similar error nowadays, using the following versions

E5108: Error executing lua: ....local/share/nvim/lazy/trouble.nvim/lua/trouble/view.lua:392: Invalid window id: 1009
stack traceback:
        [C]: in function 'get_cursor'
        ....local/share/nvim/lazy/trouble.nvim/lua/trouble/view.lua:392: in function 'get_line'
        ....local/share/nvim/lazy/trouble.nvim/lua/trouble/view.lua:406: in function 'next_item'
        ....local/share/nvim/lazy/trouble.nvim/lua/trouble/init.lua:267: in function 'next'
        /home/amtoine/.config/nvim/lua/custom/lsp.lua:109: in function </home/amtoine/.config/nvim/lua/custom/lsp.lua:109>

i'm trying to use Trouble functions to jump around in the list of diagnostics

local nmap = function(keys, func, desc, bufnr)
  if desc then
    desc = 'LSP: ' .. desc
  end

  vim.keymap.set('n', keys, func, { buffer = bufnr, silent = true, noremap = true, desc = desc })
end

-- ...

local trouble = require("trouble")

-- ...

local jump = function(fn)
  return function() fn({skip_groups = true, jump = true}) end
end

nmap("<leader>ltj", jump(trouble.next), "Jump to next item")
nmap("<leader>ltk", jump(trouble.previous), "Jump to previous item")
nmap("<leader>ltg", jump(trouble.first), "Jump to first item")
nmap("<leader>ltG", jump(trouble.last), "Jump to last item")

-- ...

Note

  • before opening the Trouble window for the first time, the 4 bindings above don't do anything.
  • after the first time the Trouble window has been opened there are two cases
    • if the Trouble window is CLOSED: then the error appears
    • if the Trouble window is OPENED: the 4 bindings work as expected

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

Successfully merging a pull request may close this issue.

3 participants