fix: indentation issue in copilot model and openai model (#393)

This commit is contained in:
yetone 2024-08-30 15:40:40 +08:00 committed by GitHub
parent ec4d2eee0b
commit 07c1d707da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -262,14 +262,24 @@ local function get_conflict_content(content, snippets)
current_line = current_line + 1
end
local need_prepend_indentation = false
local original_start_line_indentation = Utils.get_indentation(lines[start_line] or "")
table.insert(result, "<<<<<<< HEAD")
for i = start_line, end_line do
table.insert(result, lines[i])
end
table.insert(result, "=======")
for _, line in ipairs(vim.split(snippet.content, "\n")) do
for idx, line in ipairs(vim.split(snippet.content, "\n")) do
line = line:gsub("^L%d+: ", "")
if idx == 1 then
local indentation = Utils.get_indentation(line)
need_prepend_indentation = indentation ~= original_start_line_indentation
end
if need_prepend_indentation then
line = original_start_line_indentation .. line
end
table.insert(result, line)
end