Skip to content

Commit df94463

Browse files
committed
refactor(#2942): multi instance: remove unnecessary focus_file
1 parent 660c42a commit df94463

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

lua/nvim-tree/actions/moves/sibling.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function M.fn(direction)
4949
end
5050

5151
if target_node then
52-
explorer:focus_file(target_node.absolute_path)
52+
explorer:focus_node_or_parent(target_node)
5353
end
5454
end
5555
end

lua/nvim-tree/explorer/init.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,6 @@ function Explorer:get_node_from_path(path)
599599
:iterate()
600600
end
601601

602-
---@param path string
603-
function Explorer:focus_file(path)
604-
local _, i = self:find_node(function(node)
605-
return node.absolute_path == path
606-
end)
607-
view.set_cursor({ i + 1, 1 })
608-
end
609-
610602
---Focus node passed as parameter if visible, otherwise focus first visible parent.
611603
---If none of the parents is visible focus root.
612604
---If node is nil do nothing.
@@ -619,7 +611,7 @@ function Explorer:focus_node_or_parent(node)
619611
end)
620612

621613
if found_node or node.parent == nil then
622-
require("nvim-tree.view").set_cursor({ i + 1, 1 })
614+
view.set_cursor({ i + 1, 1 })
623615
break
624616
end
625617

lua/nvim-tree/explorer/live-filter.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ function LiveFilter:clear_filter()
220220
self.explorer.renderer:draw()
221221

222222
if node then
223-
self.explorer:focus_file(node.absolute_path)
223+
self.explorer:focus_node_or_parent(node)
224224
elseif last_node then
225-
self.explorer:focus_file(last_node.absolute_path)
225+
self.explorer:focus_node_or_parent(last_node)
226226
end
227227
end
228228

lua/nvim-tree/marks/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function Marks:navigate_select()
263263
if node and not node:is(DirectoryNode) and not utils.get_win_buf_from_path(node.absolute_path) then
264264
open_file.fn("edit", node.absolute_path)
265265
elseif node then
266-
self.explorer:focus_file(node.absolute_path)
266+
self.explorer:focus_node_or_parent(node)
267267
end
268268
end)
269269
end

0 commit comments

Comments
 (0)