mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-14 01:50:27 +00:00
parent
da326d0438
commit
d345631162
@ -190,11 +190,6 @@ function M.get_default_config()
|
|||||||
---@return HarpoonListItem
|
---@return HarpoonListItem
|
||||||
create_list_item = function(config, name)
|
create_list_item = function(config, name)
|
||||||
name = 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(
|
or normalize_path(
|
||||||
vim.api.nvim_buf_get_name(
|
vim.api.nvim_buf_get_name(
|
||||||
vim.api.nvim_get_current_buf()
|
vim.api.nvim_get_current_buf()
|
||||||
@ -224,8 +219,11 @@ function M.get_default_config()
|
|||||||
---@param list HarpoonList
|
---@param list HarpoonList
|
||||||
BufLeave = function(arg, list)
|
BufLeave = function(arg, list)
|
||||||
local bufnr = arg.buf
|
local bufnr = arg.buf
|
||||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
local bufname = normalize_path(
|
||||||
local item = list:get_by_display(bufname)
|
vim.api.nvim_buf_get_name(bufnr),
|
||||||
|
list.config.get_root_dir()
|
||||||
|
)
|
||||||
|
local item = list:get_by_value(bufname)
|
||||||
|
|
||||||
if item then
|
if item then
|
||||||
local pos = vim.api.nvim_win_get_cursor(0)
|
local pos = vim.api.nvim_win_get_cursor(0)
|
||||||
|
@ -224,9 +224,15 @@ function HarpoonList:get(index)
|
|||||||
return self.items[index]
|
return self.items[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
function HarpoonList:get_by_display(name)
|
function HarpoonList:get_by_value(value)
|
||||||
local displayed = self:display()
|
local index = index_of(self.items, self._length, value, {
|
||||||
local index = index_of(displayed, #displayed, name)
|
equals = function(element, item)
|
||||||
|
if item == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return element == item.value
|
||||||
|
end,
|
||||||
|
})
|
||||||
if index == -1 then
|
if index == -1 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user