Skip to content

Commit

Permalink
fix: add default empty table for state.source
Browse files Browse the repository at this point in the history
Add nil check for state.source by providing empty table as default value to
prevent errors when source is not initialized. This ensures the code handles
undefined source gracefully.
  • Loading branch information
deathbeam committed Dec 11, 2024
1 parent db95d18 commit c2d2772
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/CopilotChat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ local function resolve_embeddings(prompt, config)
local embeddings = utils.ordered_map()
for _, context_data in ipairs(contexts) do
local context_value = M.config.contexts[context_data.name]
for _, embedding in ipairs(context_value.resolve(context_data.input, state.source)) do
for _, embedding in ipairs(context_value.resolve(context_data.input, state.source or {})) do
if embedding then
embeddings:set(embedding.filename, embedding)
end
Expand Down Expand Up @@ -460,7 +460,7 @@ local function trigger_complete()
local value_str = tostring(value)
vim.api.nvim_buf_set_text(bufnr, row - 1, col, row - 1, col, { value_str })
vim.api.nvim_win_set_cursor(0, { row, col + #value_str })
end, state.source)
end, state.source or {})
end

return
Expand Down

0 comments on commit c2d2772

Please sign in to comment.