Compare commits
2 Commits
b52f34ce9a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b869334d6 | |||
| 01ca0025dd |
+7
-1
@@ -599,7 +599,7 @@ end
|
|||||||
|
|
||||||
---@param buf? integer
|
---@param buf? integer
|
||||||
function M.stage_hunk(buf)
|
function M.stage_hunk(buf)
|
||||||
local _, state, h = cursor_hunk(buf)
|
local target, state, h = cursor_hunk(buf)
|
||||||
if not state then
|
if not state then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -616,6 +616,12 @@ function M.stage_hunk(buf)
|
|||||||
"git apply failed: %s",
|
"git apply failed: %s",
|
||||||
vim.trim(res.stderr or "")
|
vim.trim(res.stderr or "")
|
||||||
)
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local s = states[target]
|
||||||
|
if s then
|
||||||
|
s.index_sha = nil
|
||||||
|
schedule(target)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ local highlights = {
|
|||||||
TabLineFill = { bg = c.bg1 },
|
TabLineFill = { bg = c.bg1 },
|
||||||
EndOfBuffer = { fg = "NONE", bg = "NONE" },
|
EndOfBuffer = { fg = "NONE", bg = "NONE" },
|
||||||
DiffAdd = { bg = "#1a2f22" },
|
DiffAdd = { bg = "#1a2f22" },
|
||||||
DiffChange = { bg = "#15304a" },
|
|
||||||
DiffDelete = { bg = "#311c1e" },
|
|
||||||
Changed = { fg = c.yellow },
|
|
||||||
NvimTreeIndentMarker = { fg = c.bg3 },
|
NvimTreeIndentMarker = { fg = c.bg3 },
|
||||||
}
|
}
|
||||||
for kind, color in pairs(completion_kind_colors) do
|
for kind, color in pairs(completion_kind_colors) do
|
||||||
|
|||||||
@@ -296,6 +296,23 @@ t.test("stage_hunk stages a deletion", function()
|
|||||||
t.eq(h.git(dir, "show", ":0:a.txt").stdout, "a\nc")
|
t.eq(h.git(dir, "show", ":0:a.txt").stdout, "a\nc")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
t.test("stage_hunk refreshes the gutter when status stays modified", function()
|
||||||
|
local _, buf = setup("a\nb\nc\nd\ne\n", "A\nb\nC\nd\nE\n")
|
||||||
|
t.eq(#assert(hunks.state(buf)).hunks, 3)
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||||
|
hunks.stage_hunk(buf)
|
||||||
|
t.wait_for(function()
|
||||||
|
return #assert(hunks.state(buf)).hunks == 2
|
||||||
|
end, "gutter to drop the first staged hunk")
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_cursor(0, { 3, 0 })
|
||||||
|
hunks.stage_hunk(buf)
|
||||||
|
t.wait_for(function()
|
||||||
|
return #assert(hunks.state(buf)).hunks == 1
|
||||||
|
end, "gutter to drop the middle staged hunk")
|
||||||
|
end)
|
||||||
|
|
||||||
t.test("reset_hunk restores the index content for a change", function()
|
t.test("reset_hunk restores the index content for a change", function()
|
||||||
local _, buf, state = setup("a\nb\nc\n", "a\nB\nc\n")
|
local _, buf, state = setup("a\nb\nc\n", "a\nB\nc\n")
|
||||||
vim.api.nvim_win_set_cursor(0, { 2, 0 })
|
vim.api.nvim_win_set_cursor(0, { 2, 0 })
|
||||||
|
|||||||
Reference in New Issue
Block a user