fix: filter out redundant backticks in editing mode (#1039)

This commit is contained in:
yetone 2025-01-05 21:15:21 +08:00 committed by GitHub
parent 369410bdb1
commit 078e9312dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,9 +163,10 @@ function Selection:create_editing_input()
local response_lines_ = vim.split(full_response, "\n") local response_lines_ = vim.split(full_response, "\n")
local response_lines = {} local response_lines = {}
for i, line in ipairs(response_lines_) do for i, line in ipairs(response_lines_) do
if not (string.match(line, "^```") and (i == 1 or i == #response_lines_)) then if string.match(line, "^```") and (i == 1 or i == #response_lines_) then goto continue end
table.insert(response_lines, line) if string.match(line, "^```$") then goto continue end
end table.insert(response_lines, line)
::continue::
end end
if #response_lines == 1 then if #response_lines == 1 then
local first_line = response_lines[1] local first_line = response_lines[1]
@ -194,6 +195,7 @@ function Selection:create_editing_input()
end end
self.prompt_input:stop_spinner() self.prompt_input:stop_spinner()
vim.defer_fn(function() self:close_editing_input() end, 0) vim.defer_fn(function() self:close_editing_input() end, 0)
Utils.debug("full response:", full_response)
end end
local filetype = api.nvim_get_option_value("filetype", { buf = code_bufnr }) local filetype = api.nvim_get_option_value("filetype", { buf = code_bufnr })