refactor(#2826): remove view debug/cc, enable new codepaths for get_winid and get_bufnr (#3169)

* refactor(#2826): fuller error messages

* refactor(#2826): winnr->winid in view/globals, remove redundant get_winid and get_bufnr calls

* refactor(#2826): winnr->winid consistently

* refactor(#2826): consistent use of buffer registry, tidy, add todos

* refactor(#2826): remove unnecessary view members float, hide_root_folder; use explorer opts

* refactor(#2826): remove unused view members centralize_selection and preserve_window_proportions

* refactor(#2826): remove unused view member height

* refactor(#2826): temporarily reuse BUFNR_PER_TAB in view constructor

* refactor(#2826): get_winid returns new after consistency check

* refactor(#2826): globals.TABPAGES -> WINID_PER_TAB

* refactor(#2826): consistent naming of tabid

* refactor(#2826): more consistency checking

* refactor(#2826): more consistency checking

* refactor(#2826): move global CURSORS to view member

* Revert "refactor(#2826): move global CURSORS to view member"

This reverts commit d84dfad1c3.

* refactor(#2826): move global CURSORS to view member

* refactor(#2826): consistency check returns new

* refactor(#2826): remove consistency checks, enabling new path for view get_winid and get_bufnr

* refactor(#2826): restore CURSORS global
This commit is contained in:
Alexander Courtis
2025-07-28 12:44:17 +10:00
committed by GitHub
parent 10db6943cb
commit a9156c0139
16 changed files with 155 additions and 420 deletions

View File

@@ -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.opts.view.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.opts.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 explorer and not explorer.view.float.quit_on_focus_loss then
if explorer and not explorer.opts.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

View File

@@ -23,7 +23,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, "open-file.usable_win_ids")
local tree_winid = explorer and explorer.view:get_winid(tabpage)
return vim.tbl_filter(function(id)
local bufid = vim.api.nvim_win_get_buf(id)
@@ -196,7 +196,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(nil, "open-file.open_file_in_tab")
explorer.view:close()
end
end
if M.relative_path then
@@ -209,7 +209,7 @@ 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")
explorer.view:close()
end
end
if M.relative_path then
@@ -222,7 +222,7 @@ 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")
explorer.view:close()
end
end
if M.relative_path then
@@ -352,7 +352,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.opts.view.float.enable then
-- ignore "WinLeave" autocmd on preview
-- because the registered "WinLeave"
-- will kill the floating window immediately
@@ -453,7 +453,7 @@ function M.fn(mode, filename)
end
if M.quit_on_open and explorer then
explorer.view:close(nil, "open-file.fn")
explorer.view:close()
end
end

View File

@@ -85,7 +85,7 @@ M.force_dirchange = add_profiling_to(function(foldername, should_open_view)
if should_change_dir() then
cd(M.options.global, foldername)
end
core.init(foldername, "change-dir")
core.init(foldername)
end
if should_open_view then

View File

@@ -44,7 +44,7 @@ function M.fn(opts, no_focus, cwd, bang)
if explorer and explorer.view:is_visible() then
-- close
explorer.view:close(nil, "toggle.fn")
explorer.view:close()
else
-- open
lib.open({