Skip to content

Commit 4401f75

Browse files
authored
feat: Add source parameter to callback function (#219)
* feat: Add source parameter to callback function The callback function in both the 'ask' and 'config' methods now receives the 'source' parameter. This allows users to access information about the source of the response, such as the buffer number and window number. This change enhances the flexibility and usability of the callback function. * feat: Add source parameter to callback function The callback function in both the 'ask' and 'config' methods now receives the 'source' parameter. This allows users to access information about the source of the response, such as the buffer number and window number. This change enhances the flexibility and usability of the callback function. * fix(CopilotChat.txt): revert change * revert txt change
1 parent 8acd46e commit 4401f75

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lua/CopilotChat/config.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ local select = require('CopilotChat.select')
2121
---@field kind string?
2222
---@field mapping string?
2323
---@field system_prompt string?
24-
---@field callback fun(response: string)?
24+
---@field callback fun(response: string, source: CopilotChat.config.source)?
2525
---@field selection nil|fun(source: CopilotChat.config.source):CopilotChat.config.selection?
2626

2727
---@class CopilotChat.config.window
@@ -68,7 +68,7 @@ local select = require('CopilotChat.select')
6868
---@field clear_chat_on_new_prompt boolean?
6969
---@field context string?
7070
---@field history_path string?
71-
---@field callback fun(response: string)?
71+
---@field callback fun(response: string, source: CopilotChat.config.source)?
7272
---@field selection nil|fun(source: CopilotChat.config.source):CopilotChat.config.selection?
7373
---@field prompts table<string, CopilotChat.config.prompt|string>?
7474
---@field window CopilotChat.config.window?

lua/CopilotChat/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function M.ask(prompt, config, source)
413413
state.chat:finish()
414414
end
415415
if config.callback then
416-
config.callback(response)
416+
config.callback(response, state.source)
417417
end
418418
if config.auto_follow_cursor and config.auto_insert_mode and state.chat:active() then
419419
vim.cmd('startinsert')

0 commit comments

Comments
 (0)