From 65d652dccd67394182c3d2206c5ba8f67d590666 Mon Sep 17 00:00:00 2001 From: mpaulson Date: Fri, 3 Nov 2023 18:13:46 -0600 Subject: [PATCH] fix: dedupe prepend --- lua/harpoon2/list.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/harpoon2/list.lua b/lua/harpoon2/list.lua index 269ee35..fe7727d 100644 --- a/lua/harpoon2/list.lua +++ b/lua/harpoon2/list.lua @@ -44,7 +44,11 @@ end ---@return HarpoonList function HarpoonList:prepend(item) item = item or self.config.add() - table.insert(self.items, 1, item) + local index = index_of(self.config, self.items, item) + if index == -1 then + table.insert(self.items, 1, item) + end + return self end