Compare commits
No commits in common. "3ee972a6edf4c4560aed1d6a2a61748b488953fe" and "6040c054cb5ca33136697421259c7a1bcbefdfe4" have entirely different histories.
3ee972a6ed
...
6040c054cb
2 changed files with 2 additions and 41 deletions
|
|
@ -247,7 +247,7 @@ end
|
||||||
|
|
||||||
---@param old_entry diffs.HunkCacheEntry
|
---@param old_entry diffs.HunkCacheEntry
|
||||||
---@param new_hunks diffs.Hunk[]
|
---@param new_hunks diffs.Hunk[]
|
||||||
---@return table<integer, true>?
|
---@return table<integer, true>
|
||||||
local function carry_forward_highlighted(old_entry, new_hunks)
|
local function carry_forward_highlighted(old_entry, new_hunks)
|
||||||
local old_hunks = old_entry.hunks
|
local old_hunks = old_entry.hunks
|
||||||
local old_hl = old_entry.highlighted
|
local old_hl = old_entry.highlighted
|
||||||
|
|
@ -288,9 +288,6 @@ local function carry_forward_highlighted(old_entry, new_hunks)
|
||||||
old_n,
|
old_n,
|
||||||
new_n
|
new_n
|
||||||
)
|
)
|
||||||
if next(highlighted) == nil then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return highlighted
|
return highlighted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -732,7 +729,6 @@ local function init()
|
||||||
ensure_cache(bufnr)
|
ensure_cache(bufnr)
|
||||||
local entry = hunk_cache[bufnr]
|
local entry = hunk_cache[bufnr]
|
||||||
if entry and entry.pending_clear then
|
if entry and entry.pending_clear then
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
|
||||||
entry.highlighted = {}
|
entry.highlighted = {}
|
||||||
entry.pending_clear = false
|
entry.pending_clear = false
|
||||||
end
|
end
|
||||||
|
|
@ -931,22 +927,12 @@ function M.get_conflict_config()
|
||||||
return config.conflict
|
return config.conflict
|
||||||
end
|
end
|
||||||
|
|
||||||
local function process_pending_clear(bufnr)
|
|
||||||
local entry = hunk_cache[bufnr]
|
|
||||||
if entry and entry.pending_clear then
|
|
||||||
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
|
||||||
entry.highlighted = {}
|
|
||||||
entry.pending_clear = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
M._test = {
|
M._test = {
|
||||||
find_visible_hunks = find_visible_hunks,
|
find_visible_hunks = find_visible_hunks,
|
||||||
hunk_cache = hunk_cache,
|
hunk_cache = hunk_cache,
|
||||||
ensure_cache = ensure_cache,
|
ensure_cache = ensure_cache,
|
||||||
invalidate_cache = invalidate_cache,
|
invalidate_cache = invalidate_cache,
|
||||||
hunks_eq = hunks_eq,
|
hunks_eq = hunks_eq,
|
||||||
process_pending_clear = process_pending_clear,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
|
|
@ -122,31 +122,6 @@ describe('decoration_provider', function()
|
||||||
assert.is_true(entry.pending_clear)
|
assert.is_true(entry.pending_clear)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('clears namespace extmarks when on_buf processes pending_clear', function()
|
|
||||||
local bufnr = create_buffer({
|
|
||||||
'M test.lua',
|
|
||||||
'@@ -1,1 +1,2 @@',
|
|
||||||
' local x = 1',
|
|
||||||
'+local y = 2',
|
|
||||||
})
|
|
||||||
diffs.attach(bufnr)
|
|
||||||
local ns_id = vim.api.nvim_create_namespace('diffs')
|
|
||||||
vim.api.nvim_buf_set_extmark(bufnr, ns_id, 0, 0, { line_hl_group = 'DiffAdd' })
|
|
||||||
assert.are.equal(1, #vim.api.nvim_buf_get_extmarks(bufnr, ns_id, 0, -1, {}))
|
|
||||||
|
|
||||||
diffs._test.invalidate_cache(bufnr)
|
|
||||||
diffs._test.ensure_cache(bufnr)
|
|
||||||
local entry = diffs._test.hunk_cache[bufnr]
|
|
||||||
assert.is_true(entry.pending_clear)
|
|
||||||
|
|
||||||
diffs._test.process_pending_clear(bufnr)
|
|
||||||
|
|
||||||
entry = diffs._test.hunk_cache[bufnr]
|
|
||||||
assert.is_false(entry.pending_clear)
|
|
||||||
assert.are.same({}, vim.api.nvim_buf_get_extmarks(bufnr, ns_id, 0, -1, {}))
|
|
||||||
delete_buffer(bufnr)
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('BufWipeout cleanup', function()
|
describe('BufWipeout cleanup', function()
|
||||||
|
|
@ -287,7 +262,7 @@ describe('decoration_provider', function()
|
||||||
|
|
||||||
local updated = diffs._test.hunk_cache[bufnr]
|
local updated = diffs._test.hunk_cache[bufnr]
|
||||||
assert.is_nil(updated.highlighted[1])
|
assert.is_nil(updated.highlighted[1])
|
||||||
assert.is_true(updated.pending_clear)
|
assert.is_false(updated.pending_clear)
|
||||||
delete_buffer(bufnr)
|
delete_buffer(bufnr)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue