test(git): speed up the hunks test setup with a flush hook
This commit is contained in:
@@ -399,6 +399,11 @@ end
|
|||||||
|
|
||||||
local schedule, sched_handle = util.keyed_debounce(recompute, 100)
|
local schedule, sched_handle = util.keyed_debounce(recompute, 100)
|
||||||
|
|
||||||
|
---@param buf integer
|
||||||
|
function M._flush(buf)
|
||||||
|
sched_handle.flush(buf)
|
||||||
|
end
|
||||||
|
|
||||||
---@param buf integer
|
---@param buf integer
|
||||||
function M.attach(buf)
|
function M.attach(buf)
|
||||||
if states[buf] then
|
if states[buf] then
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ local function setup(committed, worktree, file)
|
|||||||
vim.cmd.edit(dir .. "/" .. file)
|
vim.cmd.edit(dir .. "/" .. file)
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
hunks.attach(buf)
|
hunks.attach(buf)
|
||||||
|
hunks._flush(buf)
|
||||||
t.wait_for(function()
|
t.wait_for(function()
|
||||||
local s = hunks.state(buf)
|
local s = hunks.state(buf)
|
||||||
return s ~= nil and s.index ~= nil
|
return s ~= nil and s.index ~= nil
|
||||||
@@ -135,6 +136,7 @@ t.test("editing the buffer refreshes signs", function()
|
|||||||
t.eq(#state.hunks, 0)
|
t.eq(#state.hunks, 0)
|
||||||
vim.api.nvim_buf_set_lines(buf, 1, 2, false, { "CHANGED" })
|
vim.api.nvim_buf_set_lines(buf, 1, 2, false, { "CHANGED" })
|
||||||
vim.api.nvim_exec_autocmds("TextChanged", { buffer = buf })
|
vim.api.nvim_exec_autocmds("TextChanged", { buffer = buf })
|
||||||
|
hunks._flush(buf)
|
||||||
t.wait_for(function()
|
t.wait_for(function()
|
||||||
local s = assert(hunks.state(buf))
|
local s = assert(hunks.state(buf))
|
||||||
return #s.hunks == 1
|
return #s.hunks == 1
|
||||||
|
|||||||
Reference in New Issue
Block a user