@@ -1763,7 +1763,7 @@ M.Prompt = function(params, target, agent, template, prompt, whisper, callback)
1763
1763
local fl = qt .first_line
1764
1764
local ll = qt .last_line
1765
1765
-- remove empty lines from the start and end of the response
1766
- while true do
1766
+ while fl < ll do
1767
1767
-- get content of first_line and last_line
1768
1768
flc = vim .api .nvim_buf_get_lines (buf , fl , fl + 1 , false )[1 ]
1769
1769
llc = vim .api .nvim_buf_get_lines (buf , ll , ll + 1 , false )[1 ]
@@ -1780,11 +1780,6 @@ M.Prompt = function(params, target, agent, template, prompt, whisper, callback)
1780
1780
break
1781
1781
end
1782
1782
1783
- -- break loop lines are equal
1784
- if fl >= ll then
1785
- break
1786
- end
1787
-
1788
1783
if not flm then
1789
1784
M .helpers .undojoin (buf )
1790
1785
vim .api .nvim_buf_set_lines (buf , fl , fl + 1 , false , {})
@@ -1796,7 +1791,7 @@ M.Prompt = function(params, target, agent, template, prompt, whisper, callback)
1796
1791
end
1797
1792
1798
1793
-- if fl and ll starts with triple backticks, remove these lines
1799
- if flc and llc and flc :match (" ^%s*```" ) and llc :match (" ^%s*```" ) then
1794
+ if fl < ll and flc and llc and flc :match (" ^%s*```" ) and llc :match (" ^%s*```" ) then
1800
1795
-- remove first line with undojoin
1801
1796
M .helpers .undojoin (buf )
1802
1797
vim .api .nvim_buf_set_lines (buf , fl , fl + 1 , false , {})
0 commit comments