Skip to content

bug: invalid window when toggling cli window before the cli tool initializes #189

@Aqothy

Description

@Aqothy

Did you check docs and existing issues?

  • I have read all the sidekick.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of sidekick.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.12.0-dev-1555+g1fddd74da7

Operating system/version

Mac 26.0.1

Describe the bug

when i open an ai cli tool using sidekick, if i toggle it to hide the window before the cli tool is fully initialized, i get: vim.schedule callback: ...re/nvim/lazy/sidekick.nvim/lua/sidekick/cli/terminal.lua:253: Invalid 'window': Expected Lua number
stack traceback:
[C]: in function 'nvim_win_get_cursor'
...re/nvim/lazy/sidekick.nvim/lua/sidekick/cli/terminal.lua:253: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>

video:
Image

Steps To Reproduce

  1. toggle sidekick cli
  2. toggle it again to hide the window before the ai tool fully initializes
  3. get invalid window error spam

Expected Behavior

no error when hiding sidekick cli window before it fully initializes

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{
			"folke/sidekick.nvim",
			opts = {},
			keys = {
				{
					"<c-.>",
					function()
						require("sidekick.cli").toggle()
					end,
					desc = "Sidekick Toggle",
					mode = { "n", "t", "i" },
				},
			},
		},
		-- add any other plugins here
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions