Skip to content

Commit

Permalink
fix: cursor applying diff (#1387)
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Feb 25, 2025
1 parent e7ffb76 commit 481a44f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/avante/sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1261,12 +1261,21 @@ function Sidebar:apply(current_cursor)
local prev_start_a = 1
for _, hunk in ipairs(patch) do
local start_a, count_a, start_b, count_b = unpack(hunk)
vim.list_extend(new_lines, vim.list_slice(original_code_lines, prev_start_a, start_a - 1))
if count_a > 0 then
vim.list_extend(new_lines, vim.list_slice(original_code_lines, prev_start_a, start_a - 1))
else
vim.list_extend(new_lines, vim.list_slice(original_code_lines, prev_start_a, start_a))
end
prev_start_a = start_a + count_a
if count_a == 0 then prev_start_a = prev_start_a + 1 end
table.insert(new_lines, "<<<<<<< HEAD")
vim.list_extend(new_lines, vim.list_slice(original_code_lines, start_a, start_a + count_a - 1))
if count_a > 0 then
vim.list_extend(new_lines, vim.list_slice(original_code_lines, start_a, start_a + count_a - 1))
end
table.insert(new_lines, "=======")
vim.list_extend(new_lines, vim.list_slice(resp_lines, start_b, start_b + count_b - 1))
if count_b > 0 then
vim.list_extend(new_lines, vim.list_slice(resp_lines, start_b, start_b + count_b - 1))
end
table.insert(new_lines, ">>>>>>> Snippet")
end

Expand Down

0 comments on commit 481a44f

Please sign in to comment.