This commit is contained in:
committed by
GitHub
parent
48e76bc031
commit
ce3604d33c
@@ -1,7 +1,6 @@
|
||||
local utils = require'nvim-tree.utils'
|
||||
local view = require'nvim-tree.view'
|
||||
local diagnostics = require'nvim-tree.diagnostics'
|
||||
local _icons = require"nvim-tree.renderer.icons"
|
||||
local renderer = require"nvim-tree.renderer"
|
||||
local lib = function() return require'nvim-tree.lib' end
|
||||
|
||||
@@ -106,11 +105,42 @@ function M.sibling(direction)
|
||||
end
|
||||
|
||||
function M.find_git_item(where)
|
||||
local icon_state = _icons.get_config()
|
||||
local flags = where == 'prev' and 'b' or ''
|
||||
local icons = table.concat(vim.tbl_values(icon_state.icons.git_icons), '\\|')
|
||||
return function()
|
||||
return icon_state.show_git_icon and vim.fn.search(icons, flags)
|
||||
local node_cur = lib().get_node_at_cursor()
|
||||
local nodes_by_line = lib().get_nodes_by_line(TreeExplorer.nodes, view.View.hide_root_folder and 1 or 2)
|
||||
|
||||
local cur, first, prev, nex = nil, nil, nil, nil
|
||||
for line, node in pairs(nodes_by_line) do
|
||||
if not first and node.git_status then
|
||||
first = line
|
||||
end
|
||||
|
||||
if node == node_cur then
|
||||
cur = line
|
||||
elseif node.git_status then
|
||||
if not cur then
|
||||
prev = line
|
||||
end
|
||||
if cur and not nex then
|
||||
nex = line
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if where == 'prev' then
|
||||
if prev then
|
||||
view.set_cursor({prev, 0})
|
||||
end
|
||||
else
|
||||
if cur then
|
||||
if nex then
|
||||
view.set_cursor({nex, 0})
|
||||
end
|
||||
elseif first then
|
||||
view.set_cursor({first, 0})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user