refactor(#2942): multi instance: remove unnecessary focus_file

This commit is contained in:
Alexander Courtis 2025-09-08 16:18:09 +10:00
parent 660c42a0ac
commit df94463e76
4 changed files with 5 additions and 13 deletions

View File

@ -49,7 +49,7 @@ function M.fn(direction)
end
if target_node then
explorer:focus_file(target_node.absolute_path)
explorer:focus_node_or_parent(target_node)
end
end
end

View File

@ -599,14 +599,6 @@ function Explorer:get_node_from_path(path)
:iterate()
end
---@param path string
function Explorer:focus_file(path)
local _, i = self:find_node(function(node)
return node.absolute_path == path
end)
view.set_cursor({ i + 1, 1 })
end
---Focus node passed as parameter if visible, otherwise focus first visible parent.
---If none of the parents is visible focus root.
---If node is nil do nothing.
@ -619,7 +611,7 @@ function Explorer:focus_node_or_parent(node)
end)
if found_node or node.parent == nil then
require("nvim-tree.view").set_cursor({ i + 1, 1 })
view.set_cursor({ i + 1, 1 })
break
end

View File

@ -220,9 +220,9 @@ function LiveFilter:clear_filter()
self.explorer.renderer:draw()
if node then
self.explorer:focus_file(node.absolute_path)
self.explorer:focus_node_or_parent(node)
elseif last_node then
self.explorer:focus_file(last_node.absolute_path)
self.explorer:focus_node_or_parent(last_node)
end
end

View File

@ -263,7 +263,7 @@ function Marks:navigate_select()
if node and not node:is(DirectoryNode) and not utils.get_win_buf_from_path(node.absolute_path) then
open_file.fn("edit", node.absolute_path)
elseif node then
self.explorer:focus_file(node.absolute_path)
self.explorer:focus_node_or_parent(node)
end
end)
end