diff --git a/lua/hunk/api/signs.lua b/lua/hunk/api/signs.lua index e9e397f..65ea559 100644 --- a/lua/hunk/api/signs.lua +++ b/lua/hunk/api/signs.lua @@ -17,6 +17,12 @@ local M = { }, } +function M.clear_signs(buf) + vim.fn.sign_unplace("Hunk", { + buffer = buf, + }) +end + function M.place_sign(buf, sign, linenr) vim.fn.sign_place(0, "Hunk", sign.name, buf, { lnum = linenr, diff --git a/lua/hunk/ui/file.lua b/lua/hunk/ui/file.lua index 5d9be43..12dc909 100644 --- a/lua/hunk/ui/file.lua +++ b/lua/hunk/ui/file.lua @@ -66,6 +66,8 @@ function M.create(window, params) end local function apply_signs() + api.signs.clear_signs(buf) + for _, hunk in ipairs(params.change.hunks) do for i in utils.hunk_lines(hunk[params.side]) do local is_selected = params.change.selected_lines[params.side][i] diff --git a/lua/hunk/ui/tree.lua b/lua/hunk/ui/tree.lua index 74ff242..27535c0 100644 --- a/lua/hunk/ui/tree.lua +++ b/lua/hunk/ui/tree.lua @@ -218,6 +218,7 @@ function M.create(opts) function Component.render() tree:render() + signs.clear_signs(buf) apply_signs(tree, buf) end