Revert "refactor(#2826): move global CURSORS to view member"
This reverts commit d84dfad1c3.
This commit is contained in:
parent
d84dfad1c3
commit
82cc80ffa4
@ -19,7 +19,6 @@ local Class = require("nvim-tree.classic")
|
||||
---@field private max_width integer
|
||||
---@field private padding integer
|
||||
---@field private bufnr_by_tabid table<integer, integer> stored per tab until multi-instance is complete
|
||||
---@field private cursor integer[] as per vim.api.nvim_win_get_cursor
|
||||
local View = Class:extend()
|
||||
|
||||
---@class View
|
||||
@ -236,12 +235,12 @@ local function switch_buf_if_last_buf()
|
||||
end
|
||||
end
|
||||
|
||||
---save any state that should be preserved on reopening
|
||||
---save_tab_state saves any state that should be preserved across redraws.
|
||||
---@private
|
||||
---@param tabid integer
|
||||
function View:save_tab_state(tabid)
|
||||
tabid = tabid or vim.api.nvim_get_current_tabpage()
|
||||
self.cursor = vim.api.nvim_win_get_cursor(self:get_winid(tabid, "View:save_tab_state") or 0)
|
||||
globals.CURSORS[tabid] = vim.api.nvim_win_get_cursor(self:get_winid(tabid, "View:save_tab_state") or 0)
|
||||
end
|
||||
|
||||
---@private
|
||||
@ -609,9 +608,9 @@ function View:api_winid(opts)
|
||||
end
|
||||
end
|
||||
|
||||
--- restore any state from last close
|
||||
function View:restore_state()
|
||||
self:set_cursor(self.cursor)
|
||||
--- Restores the state of a NvimTree window if it was initialized before.
|
||||
function View:restore_tab_state()
|
||||
self:set_cursor(globals.CURSORS[vim.api.nvim_get_current_tabpage()])
|
||||
end
|
||||
|
||||
--- winid containing the buffer
|
||||
|
||||
@ -4,6 +4,7 @@ local M = {
|
||||
-- from View
|
||||
WINID_BY_TABID = {},
|
||||
BUFNR_BY_TABID = {},
|
||||
CURSORS = {},
|
||||
}
|
||||
|
||||
return M
|
||||
|
||||
@ -135,8 +135,9 @@ function M.open(opts)
|
||||
open_view_and_draw()
|
||||
end
|
||||
|
||||
-- TODO multi-instance is this actually necessary?
|
||||
if explorer then
|
||||
explorer.view:restore_state()
|
||||
explorer.view:restore_tab_state()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user