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

@@ -105,12 +105,9 @@ function Explorer:create_autocmds()
vim.api.nvim_create_autocmd("WinLeave", {
group = self.augroup_id,
pattern = "NvimTree_*",
callback = function(data)
if self.opts.experimental.multi_instance then
log.line("dev", "WinLeave %s", vim.inspect(data, { newline = "" }))
end
callback = function()
if utils.is_nvim_tree_buf(0) then
self.view:close(nil, "WinLeave")
self.view:close()
end
end,
})
@@ -172,10 +169,7 @@ function Explorer:create_autocmds()
vim.api.nvim_create_autocmd("BufWipeout", {
group = self.augroup_id,
pattern = "NvimTree_*",
callback = function(data)
if self.opts.experimental.multi_instance then
log.line("dev", "BufWipeout %s", vim.inspect(data, { newline = "" }))
end
callback = function()
if not utils.is_nvim_tree_buf(0) then
return
end
@@ -554,7 +548,7 @@ end
---nil on no explorer or invalid view win
---@return integer[]|nil
function Explorer:get_cursor_position()
local winnr = self.view:get_winnr(nil, "Explorer:get_cursor_position")
local winnr = self.view:get_winid()
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
return
end