@@ -19,7 +19,6 @@ 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
2322local View = Class :extend ()
2423
2524--- @class View
@@ -236,12 +235,12 @@ local function switch_buf_if_last_buf()
236235 end
237236end
238237
239- --- save any state that should be preserved on reopening
238+ --- save_tab_state saves any state that should be preserved across redraws.
240239--- @private
241240--- @param tabid integer
242241function View :save_tab_state (tabid )
243242 tabid = tabid or vim .api .nvim_get_current_tabpage ()
244- self . cursor = vim .api .nvim_win_get_cursor (self :get_winid (tabid , " View:save_tab_state" ) or 0 )
243+ globals . CURSORS [ tabid ] = vim .api .nvim_win_get_cursor (self :get_winid (tabid , " View:save_tab_state" ) or 0 )
245244end
246245
247246--- @private
@@ -609,9 +608,9 @@ function View:api_winid(opts)
609608 end
610609end
611610
612- --- restore any state from last close
613- function View :restore_state ()
614- self :set_cursor (self . cursor )
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 ()] )
615614end
616615
617616--- winid containing the buffer
0 commit comments