* refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class, WIP * refactor(#2826): singleton View class * refactor(#2826): View is an Explorer member * refactor(#2826): move autocmds to Explorer * refactor(#2826): API uses Explorer's View * refactor(#2826): move View into Explorer package * refactor(#2826): retain necessary view globals * refactor(#2826): move all winhl to appearance constants * refactor(#2826): add lifecycle logging to all Explorer members * refactor(#2826): fix bad cherry-pick * refactor(#2826): better enumerate_options function * refactor(#2826): add View.tab_line for debugging * refactor(#2826): default lifecycle log off * refactor(#2826): add experimental.multi_instance_debug, split globals out of view, move diagnostics to its own module * refactor(#2826): instrument View:get_winnr * refactor(#2826): instrument View:setup_tabpage * refactor(#2826): instrument View:set_current_win, View:prevent_buffer_override * refactor(#2826): instrument View:get_bufnr * refactor(#2826): track member bufnr -> winid with global * refactor(#2826): tidy experiment names and logs * vim: nvim-tree: track bufnr via buffer-update channel * vim: nvim-tree: more logging * vim: nvim-tree: revert: track bufnr via buffer-update channel * refactor(#2826): notify error on view winid and bufnr mismatches * refactor(#2826): notify error on view winid and bufnr mismatches * refactor(#2826): explorer init logging
This commit is contained in:
committed by
GitHub
parent
d54a1875a9
commit
0a06f65bf0
@@ -1,7 +1,6 @@
|
||||
local core = require("nvim-tree.core")
|
||||
local utils = require("nvim-tree.utils")
|
||||
local events = require("nvim-tree.events")
|
||||
local view = require("nvim-tree.view")
|
||||
local lib = require("nvim-tree.lib")
|
||||
local notify = require("nvim-tree.notify")
|
||||
|
||||
@@ -14,10 +13,12 @@ local M = {
|
||||
|
||||
---@param windows integer[]
|
||||
local function close_windows(windows)
|
||||
local explorer = core.get_explorer()
|
||||
|
||||
-- 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 view.View.float.enable and #vim.api.nvim_list_wins() < 3 then
|
||||
if explorer and explorer.view.float.enable and #vim.api.nvim_list_wins() < 3 then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -30,16 +31,17 @@ end
|
||||
|
||||
---@param absolute_path string
|
||||
local function clear_buffer(absolute_path)
|
||||
local explorer = core.get_explorer()
|
||||
local bufs = vim.fn.getbufinfo({ bufloaded = 1, buflisted = 1 })
|
||||
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 view.View.float.enable) then
|
||||
if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.view.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 not view.View.float.quit_on_focus_loss then
|
||||
if explorer and not explorer.view.float.quit_on_focus_loss then
|
||||
vim.api.nvim_set_current_win(tree_winnr)
|
||||
end
|
||||
if M.config.actions.remove_file.close_window then
|
||||
|
||||
Reference in New Issue
Block a user