Skip to content

Commit 940deef

Browse files
committed
refactor(#2826): restore CURSORS global
1 parent e6a0385 commit 940deef

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lua/nvim-tree/explorer/view.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ local Class = require("nvim-tree.classic")
2020
---@field private padding integer
2121
-- TODO multi-instance remove or replace with single member
2222
---@field private bufnr_by_tabid table<integer, integer>
23-
-- TODO multi-instance change to single member
24-
---@field private cursors_by_tabid table<integer, integer[]> as per vim.api.nvim_win_get_cursor
2523
local View = Class:extend()
2624

2725
---@class View
@@ -40,7 +38,6 @@ function View:new(args)
4038
self.side = (self.explorer.opts.view.side == "right") and "right" or "left"
4139
self.live_filter = { prev_focused_node = nil, }
4240
self.bufnr_by_tabid = {}
43-
self.cursors_by_tabid = {}
4441

4542
self.winopts = {
4643
relativenumber = self.explorer.opts.view.relativenumber,
@@ -244,7 +241,7 @@ end
244241
---@param tabid integer
245242
function View:save_state(tabid)
246243
tabid = tabid or vim.api.nvim_get_current_tabpage()
247-
self.cursors_by_tabid[tabid] = vim.api.nvim_win_get_cursor(self:get_winid(tabid) or 0)
244+
globals.CURSORS[tabid] = vim.api.nvim_win_get_cursor(self:get_winid(tabid) or 0)
248245
end
249246

250247
---@private
@@ -528,7 +525,7 @@ end
528525

529526
---restore any state from last close
530527
function View:restore_state()
531-
self:set_cursor(self.cursors_by_tabid[vim.api.nvim_get_current_tabpage()])
528+
self:set_cursor(globals.CURSORS[vim.api.nvim_get_current_tabpage()])
532529
end
533530

534531
--- winid containing the buffer

lua/nvim-tree/globals.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local M = {
44
-- from View
55
WINID_BY_TABID = {},
66
BUFNR_BY_TABID = {},
7+
CURSORS = {},
78
}
89

910
return M

0 commit comments

Comments
 (0)