mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
parent
da326d0438
commit
d345631162
@ -190,11 +190,6 @@ function M.get_default_config()
|
||||
---@return HarpoonListItem
|
||||
create_list_item = function(config, name)
|
||||
name = name
|
||||
-- TODO: should we do path normalization???
|
||||
-- i know i have seen sometimes it becoming an absolute
|
||||
-- path, if that is the case we can use the context to
|
||||
-- store the bufname and then have value be the normalized
|
||||
-- value
|
||||
or normalize_path(
|
||||
vim.api.nvim_buf_get_name(
|
||||
vim.api.nvim_get_current_buf()
|
||||
@ -224,8 +219,11 @@ function M.get_default_config()
|
||||
---@param list HarpoonList
|
||||
BufLeave = function(arg, list)
|
||||
local bufnr = arg.buf
|
||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||
local item = list:get_by_display(bufname)
|
||||
local bufname = normalize_path(
|
||||
vim.api.nvim_buf_get_name(bufnr),
|
||||
list.config.get_root_dir()
|
||||
)
|
||||
local item = list:get_by_value(bufname)
|
||||
|
||||
if item then
|
||||
local pos = vim.api.nvim_win_get_cursor(0)
|
||||
|
@ -224,9 +224,15 @@ function HarpoonList:get(index)
|
||||
return self.items[index]
|
||||
end
|
||||
|
||||
function HarpoonList:get_by_display(name)
|
||||
local displayed = self:display()
|
||||
local index = index_of(displayed, #displayed, name)
|
||||
function HarpoonList:get_by_value(value)
|
||||
local index = index_of(self.items, self._length, value, {
|
||||
equals = function(element, item)
|
||||
if item == nil then
|
||||
return false
|
||||
end
|
||||
return element == item.value
|
||||
end,
|
||||
})
|
||||
if index == -1 then
|
||||
return nil
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user