Skip to content

Commit 7d5eb7e

Browse files
committed
remove redundant method
1 parent 9d71f97 commit 7d5eb7e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lua/copilot/handlers.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ local lsp_handlers = {
77

88
local handlers = {
99
["PanelSolution"] = function (_, result, _, config)
10-
if result then
11-
for _, callback in pairs(config.callbacks) do
12-
callback(result)
13-
end
14-
end
10+
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
1513
end,
14+
1615
["PanelSolutionsDone"] = function (_, _, _, config)
1716
for _, callback in pairs(config.callbacks) do
1817
callback()
1918
end
2019
end
2120
}
2221

23-
-- require name so not confusing
2422
lsp_handlers.add_handler_callback = function (handler, fn_name, fn)
2523
lsp_handlers.callbacks[handler][fn_name] = fn
2624
vim.lsp.handlers[handler] = vim.lsp.with(handlers[handler], {
@@ -35,4 +33,10 @@ lsp_handlers.remove_handler_callback = function (handler, fn_name)
3533
})
3634
end
3735

36+
lsp_handlers.remove_all_name = function (fn_name)
37+
for handler, _ in pairs(lsp_handlers.callbacks) do
38+
lsp_handlers.remove_handler_callback(handler, fn_name)
39+
end
40+
end
41+
3842
return lsp_handlers

0 commit comments

Comments
 (0)