@@ -19,6 +19,7 @@ local Class = require("nvim-tree.classic")
1919--- @field private max_width integer
2020--- @field private padding integer
2121--- @field private bufnr_by_tabid table<integer , integer> stored per tab until multi-instance is complete
22+ --- @field private cursor integer[] as per vim.api.nvim_win_get_cursor
2223local View = Class :extend ()
2324
2425--- @class View
@@ -235,12 +236,12 @@ local function switch_buf_if_last_buf()
235236 end
236237end
237238
238- --- save_tab_state saves any state that should be preserved across redraws.
239+ --- save any state that should be preserved on reopening
239240--- @private
240241--- @param tabid integer
241242function View :save_tab_state (tabid )
242243 tabid = tabid or vim .api .nvim_get_current_tabpage ()
243- globals . CURSORS [ tabid ] = vim .api .nvim_win_get_cursor (self :get_winid (tabid , " View:save_tab_state" ) or 0 )
244+ self . cursor = vim .api .nvim_win_get_cursor (self :get_winid (tabid , " View:save_tab_state" ) or 0 )
244245end
245246
246247--- @private
@@ -608,9 +609,9 @@ function View:api_winid(opts)
608609 end
609610end
610611
611- --- Restores the state of a NvimTree window if it was initialized before.
612- function View :restore_tab_state ()
613- self :set_cursor (globals . CURSORS [ vim . api . nvim_get_current_tabpage ()] )
612+ --- restore any state from last close
613+ function View :restore_state ()
614+ self :set_cursor (self . cursor )
614615end
615616
616617--- winid containing the buffer
0 commit comments