Skip to content

Commit 3c8f43a

Browse files
committed
wip
1 parent 503c079 commit 3c8f43a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lua/codecompanion/diff/init.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ local diff_fn = vim.text.diff or vim.diff
5050
---@class CC.DiffText
5151
---@field text string
5252
---@field lines string[]
53-
---@field virt_lines CodeCompanion.Text[]
53+
---@field virt_lines? CodeCompanion.Text[]
5454

5555
---@alias CodeCompanion.Pos {[1]:number, [2]:number}
5656

@@ -164,7 +164,7 @@ function M._diff_lines(diff)
164164
row = row,
165165
col = 0,
166166
virt_lines_above = true,
167-
virt_lines = data.virt_lines,
167+
virt_lines = diff_utils.extend_vl(data.virt_lines, "CodeCompanionDiffDelete"),
168168
})
169169
end
170170

@@ -178,6 +178,7 @@ function M._diff_lines(diff)
178178
col = 0,
179179
end_row = row + 1,
180180
hl_group = "CodeCompanionDiffAdd",
181+
hl_eol = true,
181182
})
182183
end
183184

@@ -262,10 +263,6 @@ function M.create(args)
262263
to = {
263264
lines = args.to_lines,
264265
text = to_text,
265-
virt_lines = diff_utils.create_vl(to_text, {
266-
ft = args.ft,
267-
bg = "CodeCompanionDiffAdd",
268-
}),
269266
},
270267
namespace = api.nvim_create_namespace("codecompanion_diff"),
271268
should_offset = false,

lua/codecompanion/diff/utils.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ function M.create_vl(source, opts)
157157
return ret
158158
end
159159

160+
---Extend virtual lines to full window width with background highlight
161+
---@param vl CodeCompanion.Text[]
162+
---@param hl_group string
163+
---@return CodeCompanion.Text[]
164+
function M.extend_vl(vl, hl_group)
165+
for _, vt in ipairs(vl) do
166+
table.insert(vt, { string.rep(" ", vim.o.columns), hl_group })
167+
end
168+
return vl
169+
end
170+
160171
---Split a string into words and non-words with position tracking. UTF-8 aware
161172
---@param str string
162173
---@return { word: string, start_col: number, end_col: number }[]

0 commit comments

Comments
 (0)