@@ -7,23 +7,23 @@ local models = require("codegpt.models")
7
7
8
8
local M = {}
9
9
10
- local text_popup_stream = function (stream , bufnr , start_row , start_col , end_row , end_col )
10
+ local text_popup_stream = function (job , stream , bufnr , start_row , start_col , end_row , end_col )
11
11
local popup_filetype = Config .opts .ui .text_popup_filetype
12
- Ui .popup_stream (stream , popup_filetype , bufnr , start_row , start_col , end_row , end_col )
12
+ Ui .popup_stream (job , stream , popup_filetype , bufnr , start_row , start_col , end_row , end_col )
13
13
end
14
14
15
15
M .CallbackTypes = {
16
16
[" text_popup_stream" ] = text_popup_stream ,
17
- [" text_popup" ] = function (lines , bufnr , start_row , start_col , end_row , end_col )
17
+ [" text_popup" ] = function (job , lines , bufnr , start_row , start_col , end_row , end_col )
18
18
local popup_filetype = Config .opts .ui .text_popup_filetype
19
- Ui .popup (lines , popup_filetype , bufnr , start_row , start_col , end_row , end_col )
19
+ Ui .popup (job , lines , popup_filetype , bufnr , start_row , start_col , end_row , end_col )
20
20
end ,
21
- [" code_popup" ] = function (lines , bufnr , start_row , start_col , end_row , end_col )
21
+ [" code_popup" ] = function (job , lines , bufnr , start_row , start_col , end_row , end_col )
22
22
lines = Utils .trim_to_code_block (lines )
23
23
Utils .fix_indentation (bufnr , start_row , end_row , lines )
24
- Ui .popup (lines , Utils .get_filetype (), bufnr , start_row , start_col , end_row , end_col )
24
+ Ui .popup (job , lines , Utils .get_filetype (), bufnr , start_row , start_col , end_row , end_col )
25
25
end ,
26
- [" replace_lines" ] = function (lines , bufnr , start_row , start_col , end_row , end_col )
26
+ [" replace_lines" ] = function (job , lines , bufnr , start_row , start_col , end_row , end_col )
27
27
lines = Utils .strip_reasoning (lines , " <think>" , " </think>" )
28
28
lines = Utils .trim_to_code_block (lines )
29
29
lines = Utils .remove_trailing_whitespace (lines )
@@ -32,7 +32,7 @@ M.CallbackTypes = {
32
32
Utils .replace_lines (lines , bufnr , start_row , start_col , end_row , end_col )
33
33
else
34
34
-- if the buffer is not valid, open a popup. This can happen when the user closes the previous popup window before the request is finished.
35
- Ui .popup (lines , Utils .get_filetype (), bufnr , start_row , start_col , end_row , end_col )
35
+ Ui .popup (job , lines , Utils .get_filetype (), bufnr , start_row , start_col , end_row , end_col )
36
36
end
37
37
end ,
38
38
[" custom" ] = nil ,
@@ -51,7 +51,7 @@ local function get_cmd_opts(cmd)
51
51
local is_stream = false
52
52
53
53
local model
54
- if opts .model then
54
+ if opts ~= nil and opts .model then
55
55
_ , model = models .get_model_by_name (opts .model )
56
56
else
57
57
_ , model = models .get_model ()
@@ -96,12 +96,12 @@ function M.run_cmd(command, command_args, text_selection, bounds)
96
96
local new_callback = nil
97
97
98
98
if is_stream then
99
- new_callback = function (stream )
100
- cmd_opts .callback (stream , bufnr , unpack (bounds ))
99
+ new_callback = function (stream , job )
100
+ cmd_opts .callback (job , stream , bufnr , unpack (bounds ))
101
101
end
102
102
else
103
- new_callback = function (lines ) -- called from Provider.handle_response
104
- cmd_opts .callback (lines , bufnr , unpack (bounds ))
103
+ new_callback = function (lines , job ) -- called from Provider.handle_response
104
+ cmd_opts .callback (job , lines , bufnr , unpack (bounds ))
105
105
end
106
106
end
107
107
0 commit comments