refactor(#2826): rename View to Window
This commit is contained in:
@@ -13,7 +13,7 @@ local running = {}
|
||||
---@param path string relative or absolute
|
||||
function M.fn(path)
|
||||
local explorer = core.get_explorer()
|
||||
if not explorer or not explorer.view:is_visible() then
|
||||
if not explorer or not explorer.window:is_visible() then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -83,9 +83,9 @@ function M.fn(path)
|
||||
end)
|
||||
:iterate()
|
||||
|
||||
if found and explorer.view:is_visible() then
|
||||
if found and explorer.window:is_visible() then
|
||||
explorer.renderer:draw()
|
||||
explorer.view:set_cursor({ line, 0 })
|
||||
explorer.window:set_cursor({ line, 0 })
|
||||
end
|
||||
|
||||
running[path_real] = false
|
||||
|
||||
@@ -18,7 +18,7 @@ local function close_windows(windows)
|
||||
-- Prevent from closing when the win count equals 1 or 2,
|
||||
-- where the win to remove could be the last opened.
|
||||
-- For details see #2503.
|
||||
if explorer and explorer.view.float.enable and #vim.api.nvim_list_wins() < 3 then
|
||||
if explorer and explorer.window.float.enable and #vim.api.nvim_list_wins() < 3 then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -36,12 +36,12 @@ local function clear_buffer(absolute_path)
|
||||
for _, buf in pairs(bufs) do
|
||||
if buf.name == absolute_path then
|
||||
local tree_winnr = vim.api.nvim_get_current_win()
|
||||
if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.view.float.enable) then
|
||||
if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.window.float.enable) then
|
||||
vim.api.nvim_set_current_win(buf.windows[1])
|
||||
vim.cmd(":bn")
|
||||
end
|
||||
vim.api.nvim_buf_delete(buf.bufnr, { force = true })
|
||||
if explorer and not explorer.view.float.quit_on_focus_loss then
|
||||
if explorer and not explorer.window.float.quit_on_focus_loss then
|
||||
vim.api.nvim_set_current_win(tree_winnr)
|
||||
end
|
||||
if M.config.actions.remove_file.close_window then
|
||||
|
||||
@@ -66,9 +66,9 @@ local function move(explorer, where, what, skip_gitignored)
|
||||
end
|
||||
|
||||
if nex then
|
||||
explorer.view:set_cursor({ nex, 0 })
|
||||
explorer.window:set_cursor({ nex, 0 })
|
||||
elseif vim.o.wrapscan and first then
|
||||
explorer.view:set_cursor({ first, 0 })
|
||||
explorer.window:set_cursor({ first, 0 })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -188,13 +188,13 @@ local function move_prev_recursive(explorer, what, skip_gitignored)
|
||||
|
||||
-- 4.3)
|
||||
if node_init.name == ".." then -- root node
|
||||
explorer.view:set_cursor({ 1, 0 }) -- move to root node (position 1)
|
||||
explorer.window: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
|
||||
explorer.view:set_cursor({ node_init_line, 0 })
|
||||
explorer.window:set_cursor({ node_init_line, 0 })
|
||||
end
|
||||
|
||||
-- 4.4)
|
||||
|
||||
@@ -24,7 +24,7 @@ function M.fn(should_close)
|
||||
local parent = (node:get_parent_of_group() or node).parent
|
||||
|
||||
if not parent or not parent.parent then
|
||||
node.explorer.view:set_cursor({ 1, 0 })
|
||||
node.explorer.window:set_cursor({ 1, 0 })
|
||||
return
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ function M.fn(should_close)
|
||||
return n.absolute_path == parent.absolute_path
|
||||
end)
|
||||
|
||||
node.explorer.view:set_cursor({ line + 1, 0 })
|
||||
node.explorer.window:set_cursor({ line + 1, 0 })
|
||||
if should_close then
|
||||
parent.open = false
|
||||
parent.explorer.renderer:draw()
|
||||
|
||||
@@ -22,7 +22,7 @@ local function usable_win_ids()
|
||||
local explorer = core.get_explorer()
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
local win_ids = vim.api.nvim_tabpage_list_wins(tabpage)
|
||||
local tree_winid = explorer and explorer.view:get_winnr(tabpage)
|
||||
local tree_winid = explorer and explorer.window:get_winnr(tabpage)
|
||||
|
||||
return vim.tbl_filter(function(id)
|
||||
local bufid = vim.api.nvim_win_get_buf(id)
|
||||
@@ -190,7 +190,7 @@ local function open_file_in_tab(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close()
|
||||
explorer.window:close()
|
||||
end
|
||||
end
|
||||
if M.relative_path then
|
||||
@@ -203,7 +203,7 @@ local function drop(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close()
|
||||
explorer.window:close()
|
||||
end
|
||||
end
|
||||
if M.relative_path then
|
||||
@@ -216,7 +216,7 @@ local function tab_drop(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close()
|
||||
explorer.window:close()
|
||||
end
|
||||
end
|
||||
if M.relative_path then
|
||||
@@ -240,7 +240,7 @@ local function on_preview(buf_loaded)
|
||||
end
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:focus()
|
||||
explorer.window:focus()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -312,7 +312,7 @@ local function open_in_new_window(filename, mode)
|
||||
local create_new_window = #win_ids == 1 -- This implies that the nvim-tree window is the only one
|
||||
|
||||
local new_window_side = "belowright"
|
||||
if explorer and (explorer.view.side == "right") then
|
||||
if explorer and (explorer.window.side == "right") then
|
||||
new_window_side = "aboveleft"
|
||||
end
|
||||
|
||||
@@ -346,7 +346,7 @@ local function open_in_new_window(filename, mode)
|
||||
end
|
||||
end
|
||||
|
||||
if (mode == "preview" or mode == "preview_no_picker") and explorer and explorer.view.float.enable then
|
||||
if (mode == "preview" or mode == "preview_no_picker") and explorer and explorer.window.float.enable then
|
||||
-- ignore "WinLeave" autocmd on preview
|
||||
-- because the registered "WinLeave"
|
||||
-- will kill the floating window immediately
|
||||
@@ -389,7 +389,7 @@ local function edit_in_current_buf(filename)
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
if explorer then
|
||||
explorer.view:abandon_current_window()
|
||||
explorer.window:abandon_current_window()
|
||||
end
|
||||
|
||||
if M.relative_path then
|
||||
@@ -439,7 +439,7 @@ function M.fn(mode, filename)
|
||||
end
|
||||
|
||||
if M.resize_window and explorer then
|
||||
explorer.view:resize()
|
||||
explorer.window:resize()
|
||||
end
|
||||
|
||||
if mode == "preview" or mode == "preview_no_picker" then
|
||||
@@ -447,7 +447,7 @@ function M.fn(mode, filename)
|
||||
end
|
||||
|
||||
if M.quit_on_open and explorer then
|
||||
explorer.view:close()
|
||||
explorer.window:close()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ function M.fn(opts)
|
||||
end
|
||||
|
||||
local explorer = core.get_explorer()
|
||||
if explorer and explorer.view:is_visible() then
|
||||
if explorer and explorer.window:is_visible() then
|
||||
-- focus
|
||||
if opts.focus then
|
||||
lib.set_target_win()
|
||||
explorer.view:focus()
|
||||
explorer.window:focus()
|
||||
end
|
||||
elseif opts.open then
|
||||
-- open
|
||||
|
||||
@@ -25,10 +25,10 @@ function M.fn(opts)
|
||||
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
if explorer and explorer.view:is_visible() then
|
||||
if explorer and explorer.window:is_visible() then
|
||||
-- focus
|
||||
lib.set_target_win()
|
||||
explorer.view:focus()
|
||||
explorer.window:focus()
|
||||
else
|
||||
-- open
|
||||
lib.open({
|
||||
|
||||
@@ -12,8 +12,8 @@ function M.fn(opts)
|
||||
|
||||
if opts == nil then
|
||||
-- reset to config values
|
||||
explorer.view:configure_width()
|
||||
explorer.view:resize()
|
||||
explorer.window:configure_width()
|
||||
explorer.window:resize()
|
||||
return
|
||||
end
|
||||
|
||||
@@ -21,19 +21,19 @@ function M.fn(opts)
|
||||
local width_cfg = options.width
|
||||
|
||||
if width_cfg ~= nil then
|
||||
explorer.view:configure_width(width_cfg)
|
||||
explorer.view:resize()
|
||||
explorer.window:configure_width(width_cfg)
|
||||
explorer.window:resize()
|
||||
return
|
||||
end
|
||||
|
||||
if not explorer.view:is_width_determined() then
|
||||
if not explorer.window:is_width_determined() then
|
||||
-- {absolute} and {relative} do nothing when {width} is a function.
|
||||
return
|
||||
end
|
||||
|
||||
local absolute = options.absolute
|
||||
if type(absolute) == "number" then
|
||||
explorer.view:resize(absolute)
|
||||
explorer.window:resize(absolute)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ function M.fn(opts)
|
||||
relative_size = "+" .. relative_size
|
||||
end
|
||||
|
||||
explorer.view:resize(relative_size)
|
||||
explorer.window:resize(relative_size)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,9 +42,9 @@ function M.fn(opts, no_focus, cwd, bang)
|
||||
opts.path = nil
|
||||
end
|
||||
|
||||
if explorer and explorer.view:is_visible() then
|
||||
if explorer and explorer.window:is_visible() then
|
||||
-- close
|
||||
explorer.view:close()
|
||||
explorer.window:close()
|
||||
else
|
||||
-- open
|
||||
lib.open({
|
||||
|
||||
Reference in New Issue
Block a user