refactor(#2826): singleton View class, WIP
This commit is contained in:
@@ -14,7 +14,7 @@ local running = {}
|
||||
---@param path string relative or absolute
|
||||
function M.fn(path)
|
||||
local explorer = core.get_explorer()
|
||||
if not explorer or not view.is_visible() then
|
||||
if not explorer or not view.View:is_visible() then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -84,9 +84,9 @@ function M.fn(path)
|
||||
end)
|
||||
:iterate()
|
||||
|
||||
if found and view.is_visible() then
|
||||
if found and view.View:is_visible() then
|
||||
explorer.renderer:draw()
|
||||
view.set_cursor({ line, 0 })
|
||||
view.View:set_cursor({ line, 0 })
|
||||
end
|
||||
|
||||
running[path_real] = false
|
||||
|
||||
@@ -67,9 +67,9 @@ local function move(explorer, where, what, skip_gitignored)
|
||||
end
|
||||
|
||||
if nex then
|
||||
view.set_cursor({ nex, 0 })
|
||||
view.View:set_cursor({ nex, 0 })
|
||||
elseif vim.o.wrapscan and first then
|
||||
view.set_cursor({ first, 0 })
|
||||
view.View:set_cursor({ first, 0 })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -189,13 +189,13 @@ local function move_prev_recursive(explorer, what, skip_gitignored)
|
||||
|
||||
-- 4.3)
|
||||
if node_init.name == ".." then -- root node
|
||||
view.set_cursor({ 1, 0 }) -- move to root node (position 1)
|
||||
view.View:set_cursor({ 1, 0 }) -- move to root node (position 1)
|
||||
else
|
||||
local node_init_line = utils.find_node_line(node_init)
|
||||
if node_init_line < 0 then
|
||||
return
|
||||
end
|
||||
view.set_cursor({ node_init_line, 0 })
|
||||
view.View:set_cursor({ node_init_line, 0 })
|
||||
end
|
||||
|
||||
-- 4.4)
|
||||
|
||||
@@ -25,7 +25,7 @@ function M.fn(should_close)
|
||||
local parent = (node:get_parent_of_group() or node).parent
|
||||
|
||||
if not parent or not parent.parent then
|
||||
view.set_cursor({ 1, 0 })
|
||||
view.View:set_cursor({ 1, 0 })
|
||||
return
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ function M.fn(should_close)
|
||||
return n.absolute_path == parent.absolute_path
|
||||
end)
|
||||
|
||||
view.set_cursor({ line + 1, 0 })
|
||||
view.View:set_cursor({ line + 1, 0 })
|
||||
if should_close then
|
||||
parent.open = false
|
||||
parent.explorer.renderer:draw()
|
||||
|
||||
@@ -373,7 +373,7 @@ local function is_already_loaded(filename)
|
||||
end
|
||||
|
||||
local function edit_in_current_buf(filename)
|
||||
require("nvim-tree.view").abandon_current_window()
|
||||
require("nvim-tree.view").View:abandon_current_window()
|
||||
if M.relative_path then
|
||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||
end
|
||||
@@ -419,7 +419,7 @@ function M.fn(mode, filename)
|
||||
end
|
||||
|
||||
if M.resize_window then
|
||||
view.resize()
|
||||
view.View:resize()
|
||||
end
|
||||
|
||||
if mode == "preview" or mode == "preview_no_picker" then
|
||||
|
||||
@@ -41,7 +41,7 @@ function M.fn(opts)
|
||||
return
|
||||
end
|
||||
|
||||
if view.is_visible() then
|
||||
if view.View:is_visible() then
|
||||
-- focus
|
||||
if opts.focus then
|
||||
lib.set_target_win()
|
||||
|
||||
@@ -23,7 +23,7 @@ function M.fn(opts)
|
||||
opts.path = nil
|
||||
end
|
||||
|
||||
if view.is_visible() then
|
||||
if view.View:is_visible() then
|
||||
-- focus
|
||||
lib.set_target_win()
|
||||
view.focus()
|
||||
|
||||
@@ -8,7 +8,7 @@ function M.fn(opts)
|
||||
if opts == nil then
|
||||
-- reset to config values
|
||||
view.View:configure_width()
|
||||
view.resize()
|
||||
view.View:resize()
|
||||
return
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ function M.fn(opts)
|
||||
|
||||
if width_cfg ~= nil then
|
||||
view.View:configure_width(width_cfg)
|
||||
view.resize()
|
||||
view.View:resize()
|
||||
return
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ function M.fn(opts)
|
||||
|
||||
local absolute = options.absolute
|
||||
if type(absolute) == "number" then
|
||||
view.resize(absolute)
|
||||
view.View:resize(absolute)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ function M.fn(opts)
|
||||
relative_size = "+" .. relative_size
|
||||
end
|
||||
|
||||
view.resize(relative_size)
|
||||
view.View:resize(relative_size)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ function M.fn(opts, no_focus, cwd, bang)
|
||||
opts.path = nil
|
||||
end
|
||||
|
||||
if view.is_visible() then
|
||||
if view.View:is_visible() then
|
||||
-- close
|
||||
view.View:close()
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user