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)