fix: focus visible parent on collapse all (#2261)
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
f5804ce94e
commit
f873625d06
@ -1,6 +1,7 @@
|
|||||||
local renderer = require "nvim-tree.renderer"
|
local renderer = require "nvim-tree.renderer"
|
||||||
local utils = require "nvim-tree.utils"
|
local utils = require "nvim-tree.utils"
|
||||||
local core = require "nvim-tree.core"
|
local core = require "nvim-tree.core"
|
||||||
|
local lib = require "nvim-tree.lib"
|
||||||
local Iterator = require "nvim-tree.iterators.node-iterator"
|
local Iterator = require "nvim-tree.iterators.node-iterator"
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
@ -22,17 +23,20 @@ local function buf_match()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.fn(keep_buffers)
|
function M.fn(keep_buffers)
|
||||||
if not core.get_explorer() then
|
local node = lib.get_node_at_cursor()
|
||||||
|
local explorer = core.get_explorer()
|
||||||
|
|
||||||
|
if explorer == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local matches = buf_match()
|
local matches = buf_match()
|
||||||
|
|
||||||
Iterator.builder(core.get_explorer().nodes)
|
Iterator.builder(explorer.nodes)
|
||||||
:hidden()
|
:hidden()
|
||||||
:applier(function(node)
|
:applier(function(n)
|
||||||
if node.nodes ~= nil then
|
if n.nodes ~= nil then
|
||||||
node.open = keep_buffers == true and matches(node.absolute_path)
|
n.open = keep_buffers == true and matches(n.absolute_path)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
:recursor(function(n)
|
:recursor(function(n)
|
||||||
@ -41,6 +45,7 @@ function M.fn(keep_buffers)
|
|||||||
:iterate()
|
:iterate()
|
||||||
|
|
||||||
renderer.draw()
|
renderer.draw()
|
||||||
|
utils.focus_node_or_parent(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user