Skip to content

Commit 0b115ac

Browse files
committed
fix: avoid overriding saved cursors when opening/closing
fixes #1197
1 parent 3ac4432 commit 0b115ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lua/nvim-tree/view.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local events = require "nvim-tree.events"
66

77
M.View = {
88
tabpages = {},
9+
cursors = {},
910
hide_root_folder = false,
1011
winopts = {
1112
relativenumber = false,
@@ -158,7 +159,7 @@ end
158159
-- save_tab_state saves any state that should be preserved across redraws.
159160
local function save_tab_state()
160161
local tabpage = a.nvim_get_current_tabpage()
161-
M.View.tabpages[tabpage].cursor = a.nvim_win_get_cursor(M.get_winnr())
162+
M.View.cursors[tabpage] = a.nvim_win_get_cursor(M.get_winnr())
162163
end
163164

164165
function M.close()
@@ -305,7 +306,7 @@ end
305306
--- Restores the state of a NvimTree window if it was initialized before.
306307
function M.restore_tab_state()
307308
local tabpage = a.nvim_get_current_tabpage()
308-
M.set_cursor(M.View.tabpages[tabpage].cursor)
309+
M.set_cursor(M.View.cursors[tabpage])
309310
end
310311

311312
--- Returns the window number for nvim-tree within the tabpage specified

0 commit comments

Comments
 (0)