* Revert "fix(#3172): live filter exception (#3173)" This reverts commit0a7fcdf3f8. * Revert "refactor(#2826): move view to instanced window class (#3153)" This reverts commit0a06f65bf0. * feat(#3157): add view.cursorlineopt
This commit is contained in:
committed by
GitHub
parent
9b289abd69
commit
a4699c0904
@@ -2,8 +2,8 @@
|
||||
local lib = require("nvim-tree.lib")
|
||||
local notify = require("nvim-tree.notify")
|
||||
local utils = require("nvim-tree.utils")
|
||||
local core = require("nvim-tree.core")
|
||||
local full_name = require("nvim-tree.renderer.components.full-name")
|
||||
local view = require("nvim-tree.view")
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -20,10 +20,9 @@ end
|
||||
---Get all windows in the current tabpage that aren't NvimTree.
|
||||
---@return table with valid win_ids
|
||||
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, "open-file.usable_win_ids")
|
||||
local tree_winid = view.get_winnr(tabpage)
|
||||
|
||||
return vim.tbl_filter(function(id)
|
||||
local bufid = vim.api.nvim_win_get_buf(id)
|
||||
@@ -194,10 +193,7 @@ end
|
||||
|
||||
local function open_file_in_tab(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close(nil, "open-file.open_file_in_tab")
|
||||
end
|
||||
view.close()
|
||||
end
|
||||
if M.relative_path then
|
||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||
@@ -207,10 +203,7 @@ end
|
||||
|
||||
local function drop(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close(nil, "open-file.drop")
|
||||
end
|
||||
view.close()
|
||||
end
|
||||
if M.relative_path then
|
||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||
@@ -220,10 +213,7 @@ end
|
||||
|
||||
local function tab_drop(filename)
|
||||
if M.quit_on_open then
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:close(nil, "open-file.tab_drop")
|
||||
end
|
||||
view.close()
|
||||
end
|
||||
if M.relative_path then
|
||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||
@@ -244,10 +234,7 @@ local function on_preview(buf_loaded)
|
||||
once = true,
|
||||
})
|
||||
end
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
explorer.view:focus()
|
||||
end
|
||||
view.focus()
|
||||
end
|
||||
|
||||
local function get_target_winid(mode)
|
||||
@@ -292,8 +279,6 @@ local function set_current_win_no_autocmd(winid, autocmd)
|
||||
end
|
||||
|
||||
local function open_in_new_window(filename, mode)
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
if type(mode) ~= "string" then
|
||||
mode = ""
|
||||
end
|
||||
@@ -316,11 +301,7 @@ local function open_in_new_window(filename, mode)
|
||||
end, vim.api.nvim_list_wins())
|
||||
|
||||
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
|
||||
new_window_side = "aboveleft"
|
||||
end
|
||||
local new_window_side = (view.View.side == "right") and "aboveleft" or "belowright"
|
||||
|
||||
-- Target is invalid: create new window
|
||||
if not vim.tbl_contains(win_ids, target_winid) then
|
||||
@@ -352,7 +333,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 view.View.float.enable then
|
||||
-- ignore "WinLeave" autocmd on preview
|
||||
-- because the registered "WinLeave"
|
||||
-- will kill the floating window immediately
|
||||
@@ -392,12 +373,7 @@ local function is_already_loaded(filename)
|
||||
end
|
||||
|
||||
local function edit_in_current_buf(filename)
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
if explorer then
|
||||
explorer.view:abandon_current_window()
|
||||
end
|
||||
|
||||
require("nvim-tree.view").abandon_current_window()
|
||||
if M.relative_path then
|
||||
filename = utils.path_relative(filename, vim.fn.getcwd())
|
||||
end
|
||||
@@ -408,8 +384,6 @@ end
|
||||
---@param filename string
|
||||
---@return nil
|
||||
function M.fn(mode, filename)
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
if type(mode) ~= "string" then
|
||||
mode = ""
|
||||
end
|
||||
@@ -444,16 +418,16 @@ function M.fn(mode, filename)
|
||||
vim.bo.bufhidden = ""
|
||||
end
|
||||
|
||||
if M.resize_window and explorer then
|
||||
explorer.view:resize()
|
||||
if M.resize_window then
|
||||
view.resize()
|
||||
end
|
||||
|
||||
if mode == "preview" or mode == "preview_no_picker" then
|
||||
return on_preview(buf_loaded)
|
||||
end
|
||||
|
||||
if M.quit_on_open and explorer then
|
||||
explorer.view:close(nil, "open-file.fn")
|
||||
if M.quit_on_open then
|
||||
view.close()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user