From c82d3d5e3df2fa5922934103b0c4cfd73278d2a1 Mon Sep 17 00:00:00 2001 From: mwishoff Date: Wed, 6 Dec 2023 08:40:47 -0800 Subject: [PATCH] Added harpoon_wrap option to default config as true. Reference this option in list:prev and list:next. When true allows prev and next to wrap the harpoon list, when false it will not wrap the harpoon list. --- lua/harpoon/config.lua | 1 + lua/harpoon/list.lua | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index 260f004..a341492 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -74,6 +74,7 @@ function M.get_default_config() }, default = { + harpoon_wrap = true, --- select_with_nill allows for a list to call select even if the provided item is nil select_with_nil = false, diff --git a/lua/harpoon/list.lua b/lua/harpoon/list.lua index 20a44e3..4d01385 100644 --- a/lua/harpoon/list.lua +++ b/lua/harpoon/list.lua @@ -171,8 +171,11 @@ end function HarpoonList:next() self._index = self._index + 1 - if self._index > #self.items then + print(self._index) + if self._index > #self.items and self.config.harpoon_wrap then self._index = 1 + elseif self._index > #self.items and not self.config.harpoon_wrap then + self._index = #self.items end self:select(self._index) @@ -180,8 +183,11 @@ end function HarpoonList:prev() self._index = self._index - 1 - if self._index < 1 then + print(self._index) + if self._index < 1 and self.config.harpoon_wrap then self._index = #self.items + elseif self._index < 1 and not self.config.harpoon_wrap then + self._index = 1 end self:select(self._index)