mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
Merge pull request #387 from mwishoff/harpoon2
Add feature to disable/enable wrapping on next/prev when cycling through harpoon lists.
This commit is contained in:
commit
a31438258a
@ -77,6 +77,9 @@ function M.get_default_config()
|
||||
},
|
||||
|
||||
default = {
|
||||
--- ui_nav_wrap allows the ability to enable(true) or disable(false) wrapping on prev and next list calls.
|
||||
ui_nav_wrap = true,
|
||||
|
||||
--- select_with_nill allows for a list to call select even if the provided item is nil
|
||||
select_with_nil = false,
|
||||
|
||||
|
@ -179,8 +179,10 @@ end
|
||||
|
||||
function HarpoonList:next()
|
||||
self._index = self._index + 1
|
||||
if self._index > #self.items then
|
||||
if self._index > #self.items and self.config.ui_nav_wrap then
|
||||
self._index = 1
|
||||
elseif self._index > #self.items and not self.config.ui_nav_wrap then
|
||||
self._index = #self.items
|
||||
end
|
||||
|
||||
self:select(self._index)
|
||||
@ -188,8 +190,10 @@ end
|
||||
|
||||
function HarpoonList:prev()
|
||||
self._index = self._index - 1
|
||||
if self._index < 1 then
|
||||
if self._index < 1 and self.config.ui_nav_wrap then
|
||||
self._index = #self.items
|
||||
elseif self._index < 1 and not self.config.ui_nav_wrap then
|
||||
self._index = 1
|
||||
end
|
||||
|
||||
self:select(self._index)
|
||||
|
@ -1,4 +1,4 @@
|
||||
local utils = require("harpoon.test.utils")
|
||||
--local utils = require("harpoon.test.utils")
|
||||
local Logger = require("harpoon.logger")
|
||||
|
||||
local eq = assert.are.same
|
||||
|
@ -1,7 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
function M.trim(str)
|
||||
return str:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
return str:gsub("^%s+", ""):gsub("%s+$", "")
|
||||
end
|
||||
function M.remove_duplicate_whitespace(str)
|
||||
return str:gsub("%s+", " ")
|
||||
@ -11,8 +11,8 @@ function M.split(str, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t={}
|
||||
for s in string.gmatch(str, "([^"..sep.."]+)") do
|
||||
local t = {}
|
||||
for s in string.gmatch(str, "([^" .. sep .. "]+)") do
|
||||
table.insert(t, s)
|
||||
end
|
||||
return t
|
||||
|
Loading…
x
Reference in New Issue
Block a user