fix: edit supports think tag (#1430)

This commit is contained in:
yetone
2025-02-28 15:24:36 +08:00
committed by GitHub
parent 4cbba9f95e
commit 814bba5ef2
2 changed files with 49 additions and 6 deletions

View File

@@ -165,11 +165,19 @@ function Selection:create_editing_input()
full_response = full_response .. chunk
local response_lines_ = vim.split(full_response, "\n")
local response_lines = {}
for i, line in ipairs(response_lines_) do
if string.match(line, "^```") and (i == 1 or i == #response_lines_) then goto continue end
if string.match(line, "^```$") then goto continue end
table.insert(response_lines, line)
::continue::
local in_code_block = false
for _, line in ipairs(response_lines_) do
if line:match("^<code>") then
in_code_block = true
line = line:gsub("^<code>", "")
if line ~= "" then table.insert(response_lines, line) end
elseif line:match("</code>") then
in_code_block = false
line = line:gsub("</code>.*$", "")
if line ~= "" then table.insert(response_lines, line) end
elseif in_code_block then
table.insert(response_lines, line)
end
end
if #response_lines == 1 then
local first_line = response_lines[1]