From 90dc9599e344e7de6046feb0bdaf77396606e22c Mon Sep 17 00:00:00 2001 From: Will Hopkins Date: Sat, 9 Dec 2023 01:43:55 -0800 Subject: [PATCH] feat: introduce reorder event --- lua/harpoon/list.lua | 6 ++++++ lua/harpoon/listeners.lua | 1 + 2 files changed, 7 insertions(+) diff --git a/lua/harpoon/list.lua b/lua/harpoon/list.lua index 20a44e3..4b0ef20 100644 --- a/lua/harpoon/list.lua +++ b/lua/harpoon/list.lua @@ -147,6 +147,12 @@ function HarpoonList:resolve_displayed(displayed) ) new_list[i] = self.config.create_list_item(self.config, v) else + if index ~= i then + Listeners.listeners:emit( + Listeners.event_names.REORDER, + { list = self, item = self.items[index], idx = i } + ) + end local index_in_new_list = index_of(new_list, self.items[index], self.config) if index_in_new_list == -1 then diff --git a/lua/harpoon/listeners.lua b/lua/harpoon/listeners.lua index c079b63..23d7bcc 100644 --- a/lua/harpoon/listeners.lua +++ b/lua/harpoon/listeners.lua @@ -52,5 +52,6 @@ return { ADD = "ADD", SELECT = "SELECT", REMOVE = "REMOVE", + REORDER = "REORDER", }, }