Skip to content

Commit cca298c

Browse files
committed
Fix more CopilotPanel Errors
1 parent 9b32d2f commit cca298c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lua/copilot/extensions/print_panel.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ local create_win = function ()
8888
return win
8989
end
9090

91+
print_panel.insert = function ()
92+
print(vim.inspect(print_panel.entries))
93+
end
9194
print_panel.select = function (id)
9295
if not id then id = print_panel.current or 1 end
9396
local selection = print_panel.entries[id]
@@ -136,11 +139,14 @@ print_panel.create = function (bufnr)
136139
local keymaps = {
137140
["j"] = print_panel.next,
138141
["k"] = print_panel.prev,
139-
["<CR>"] = print_panel.select,
142+
["<CR>"] = print_panel.insert,
140143
}
141144

142145
for key, fn in pairs(keymaps) do
143-
vim.keymap.set("n", key, fn, {
146+
vim.keymap.set("n", key, function ()
147+
-- necessary because of possible bug
148+
return vim.api.nvim_get_current_buf() == print_panel.bufnr and fn()
149+
end, {
144150
silent = true,
145151
buffer = print_panel.bufnr,
146152
})

lua/copilot/handlers.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ local lsp_handlers = {
88
local handlers = {
99
["PanelSolution"] = function (_, result, _, config)
1010
if not result then return "err" end
11-
if result.panelId then config.callbacks[result.panelId](result)
12-
else for _, callback in pairs(config.callbacks) do callback() end end
11+
if result.panelId and config.callbacks[result.panelId] then
12+
config.callbacks[result.panelId](result)
13+
elseif not config.callbacks[result.panelId] and result.panelId then
14+
return
15+
else
16+
for _, callback in pairs(config.callbacks) do callback() end
17+
end
1318
end,
1419

1520
["PanelSolutionsDone"] = function (_, _, _, config)

0 commit comments

Comments
 (0)