feat(hunks)!: highlight inline overlay diffs

BREAKING CHANGE: rename :GitDiffOverlay to :GitHunkOverlay and <Plug>(git-diff-overlay) to <Plug>(git-hunk-overlay).
This commit is contained in:
2026-05-29 14:59:18 +02:00
parent e6616e260b
commit 351b5690c2
4 changed files with 256 additions and 16 deletions
+26 -1
View File
@@ -64,6 +64,19 @@ local function find_float()
end
end
---@param hl string|string[]?
---@param group string
---@return boolean
local function has_hl(hl, group)
if hl == group then
return true
end
if type(hl) == "table" then
return vim.tbl_contains(hl, group)
end
return false
end
t.test("pure add: hunk shape and add signs", function()
local _, buf, state = setup("a\nd\n", "a\nb\nc\nd\n")
t.eq(#state.hunks, 1, "one hunk for a pure addition")
@@ -173,7 +186,19 @@ t.test("overlay: change hunk shows deletion and addition", function()
vim.startswith(piece[1], "b"),
"deleted line shows the old content"
)
t.eq(piece[2], "GitHunkDeleteLine")
t.truthy(has_hl(piece[2], "GitHunkDeleteLine"))
t.truthy(has_hl(piece[2], "DiffText"))
local seen_inline = false
for _, m in ipairs(detailed_marks(buf, "ow.git.hunks.overlay")) do
local d = assert(m[4])
if d.hl_group == "DiffText" then
seen_inline = true
t.eq(m[2], 1, "inline addition highlight is on the changed line")
t.eq(m[3], 0, "inline addition starts at the changed byte")
t.eq(d.end_col, 1, "inline addition ends after the changed byte")
end
end
t.truthy(seen_inline, "the added side gets an inline highlight")
end)
t.test("overlay: delete hunk shows only deletion lines", function()