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

headless mode causes state.source to be nil #703

Open
josiahdenton opened this issue Jan 1, 2025 · 0 comments · May be fixed by #704
Open

headless mode causes state.source to be nil #703

josiahdenton opened this issue Jan 1, 2025 · 0 comments · May be fixed by #704

Comments

@josiahdenton
Copy link

josiahdenton commented Jan 1, 2025

When using headless mode I've noticed you must first open the buffer window for CopilotChat first otherwise any prompts that use state.source.bufnr/winnr will throw an error.

For example, if try to run the following immediately after opening nvim

local chat = require("CopilotChat")
chat.ask("/Review", {
    headless = true,
})

I would get the following error

Error executing vim.schedule lua callback: ...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: ...re/nvim/lazy/CopilotChat.nvim/lua/CopilotChat/config.lua:330: attempt to index local 'source' (a nil value)
stack traceback:
	[C]: in function 'error'
	...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'
	...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:45: in function <...share/nvim/lazy/plenary.nvim/lua/plenary/async/async.lua:44>

From what I can tell, state.source.bufnr/winnr is set at init:update_selection, which gets called on BufEnter for the Chat window. But since we don't ever open the Chat window in headless mode we don't update state.source.

@josiahdenton josiahdenton linked a pull request Jan 1, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant