refactor(#2826): winnr->winid in view/globals, remove redundant get_winid and get_bufnr calls
This commit is contained in:
parent
6e7ce8771b
commit
b7e9789850
@ -22,7 +22,7 @@ local function usable_win_ids()
|
|||||||
local explorer = core.get_explorer()
|
local explorer = core.get_explorer()
|
||||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
local win_ids = vim.api.nvim_tabpage_list_wins(tabpage)
|
local win_ids = vim.api.nvim_tabpage_list_wins(tabpage)
|
||||||
local tree_winid = explorer and explorer.view:get_winnr(tabpage, "open-file.usable_win_ids")
|
local tree_winid = explorer and explorer.view:get_winid(tabpage, "open-file.usable_win_ids")
|
||||||
|
|
||||||
return vim.tbl_filter(function(id)
|
return vim.tbl_filter(function(id)
|
||||||
local bufid = vim.api.nvim_win_get_buf(id)
|
local bufid = vim.api.nvim_win_get_buf(id)
|
||||||
|
|||||||
@ -554,7 +554,7 @@ end
|
|||||||
---nil on no explorer or invalid view win
|
---nil on no explorer or invalid view win
|
||||||
---@return integer[]|nil
|
---@return integer[]|nil
|
||||||
function Explorer:get_cursor_position()
|
function Explorer:get_cursor_position()
|
||||||
local winnr = self.view:get_winnr(nil, "Explorer:get_cursor_position")
|
local winnr = self.view:get_winid(nil, "Explorer:get_cursor_position")
|
||||||
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
|
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -88,7 +88,7 @@ local tabinitial = {
|
|||||||
-- The position of the cursor { line, column }
|
-- The position of the cursor { line, column }
|
||||||
cursor = { 0, 0 },
|
cursor = { 0, 0 },
|
||||||
-- The NvimTree window number
|
-- The NvimTree window number
|
||||||
winnr = nil,
|
winid = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type { name: string, value: any }[]
|
---@type { name: string, value: any }[]
|
||||||
@ -134,16 +134,17 @@ function View:create_buffer(bufnr)
|
|||||||
self.bufnr_by_tab[tab] = globals.BUFNR_PER_TAB[tab]
|
self.bufnr_by_tab[tab] = globals.BUFNR_PER_TAB[tab]
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_buf_set_name(self:get_bufnr("View:create_buffer1"), "NvimTree_" .. tab)
|
bufnr = self:get_bufnr("View:create_buffer")
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_name(bufnr, "NvimTree_" .. tab)
|
||||||
|
|
||||||
bufnr = self:get_bufnr("View:create_buffer2")
|
|
||||||
for _, option in ipairs(BUFFER_OPTIONS) do
|
for _, option in ipairs(BUFFER_OPTIONS) do
|
||||||
vim.api.nvim_set_option_value(option.name, option.value, { buf = bufnr })
|
vim.api.nvim_set_option_value(option.name, option.value, { buf = bufnr })
|
||||||
end
|
end
|
||||||
|
|
||||||
require("nvim-tree.keymap").on_attach(self:get_bufnr("View:create_buffer3"))
|
require("nvim-tree.keymap").on_attach(bufnr)
|
||||||
|
|
||||||
events._dispatch_tree_attached_post(self:get_bufnr("View:create_buffer4"))
|
events._dispatch_tree_attached_post(bufnr)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
@ -180,17 +181,17 @@ local move_tbl = {
|
|||||||
---@param tabpage integer
|
---@param tabpage integer
|
||||||
---@param callsite string
|
---@param callsite string
|
||||||
function View:setup_tabpage(tabpage, callsite)
|
function View:setup_tabpage(tabpage, callsite)
|
||||||
local winnr = vim.api.nvim_get_current_win()
|
local winid = vim.api.nvim_get_current_win()
|
||||||
|
|
||||||
if self.explorer.opts.experimental.multi_instance then
|
if self.explorer.opts.experimental.multi_instance then
|
||||||
log.line("dev", "View:setup_tabpage(%3s, %-20.20s) w%d %s",
|
log.line("dev", "View:setup_tabpage(%3s, %-20.20s) w%d %s",
|
||||||
tabpage,
|
tabpage,
|
||||||
callsite,
|
callsite,
|
||||||
winnr,
|
winid,
|
||||||
globals.TABPAGES[tabpage] and vim.inspect(globals.TABPAGES[tabpage], { newline = "" }) or "tabinitial")
|
globals.TABPAGES[tabpage] and vim.inspect(globals.TABPAGES[tabpage], { newline = "" }) or "tabinitial")
|
||||||
end
|
end
|
||||||
|
|
||||||
globals.TABPAGES[tabpage] = vim.tbl_extend("force", globals.TABPAGES[tabpage] or tabinitial, { winnr = winnr })
|
globals.TABPAGES[tabpage] = vim.tbl_extend("force", globals.TABPAGES[tabpage] or tabinitial, { winid = winid })
|
||||||
end
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
@ -278,7 +279,7 @@ end
|
|||||||
---@param tabnr integer
|
---@param tabnr integer
|
||||||
function View:save_tab_state(tabnr)
|
function View:save_tab_state(tabnr)
|
||||||
local tabpage = tabnr or vim.api.nvim_get_current_tabpage()
|
local tabpage = tabnr or vim.api.nvim_get_current_tabpage()
|
||||||
globals.CURSORS[tabpage] = vim.api.nvim_win_get_cursor(self:get_winnr(tabpage, "View:save_tab_state") or 0)
|
globals.CURSORS[tabpage] = vim.api.nvim_win_get_cursor(self:get_winid(tabpage, "View:save_tab_state") or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
@ -292,7 +293,7 @@ function View:close_internal(tabpage)
|
|||||||
end
|
end
|
||||||
self:save_tab_state(tabpage)
|
self:save_tab_state(tabpage)
|
||||||
switch_buf_if_last_buf()
|
switch_buf_if_last_buf()
|
||||||
local tree_win = self:get_winnr(tabpage, "View:close_internal")
|
local tree_win = self:get_winid(tabpage, "View:close_internal")
|
||||||
local current_win = vim.api.nvim_get_current_win()
|
local current_win = vim.api.nvim_get_current_win()
|
||||||
for _, win in pairs(vim.api.nvim_tabpage_list_wins(tabpage)) do
|
for _, win in pairs(vim.api.nvim_tabpage_list_wins(tabpage)) do
|
||||||
if vim.api.nvim_win_get_config(win).relative == "" then
|
if vim.api.nvim_win_get_config(win).relative == "" then
|
||||||
@ -371,7 +372,7 @@ function View:grow()
|
|||||||
local padding = self:get_size(self.padding)
|
local padding = self:get_size(self.padding)
|
||||||
|
|
||||||
-- account for sign/number columns etc.
|
-- account for sign/number columns etc.
|
||||||
local wininfo = vim.fn.getwininfo(self:get_winnr(nil, "View:grow"))
|
local wininfo = vim.fn.getwininfo(self:get_winid(nil, "View:grow"))
|
||||||
if type(wininfo) == "table" and type(wininfo[1]) == "table" then
|
if type(wininfo) == "table" and type(wininfo[1]) == "table" then
|
||||||
padding = padding + wininfo[1].textoff
|
padding = padding + wininfo[1].textoff
|
||||||
end
|
end
|
||||||
@ -440,12 +441,12 @@ function View:resize(size)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local winnr = self:get_winnr(nil, "View:resize") or 0
|
local winid = self:get_winid(nil, "View:resize") or 0
|
||||||
|
|
||||||
local new_size = self:get_width()
|
local new_size = self:get_width()
|
||||||
|
|
||||||
if new_size ~= vim.api.nvim_win_get_width(winnr) then
|
if new_size ~= vim.api.nvim_win_get_width(winid) then
|
||||||
vim.api.nvim_win_set_width(winnr, new_size)
|
vim.api.nvim_win_set_width(winid, new_size)
|
||||||
if not self.preserve_window_proportions then
|
if not self.preserve_window_proportions then
|
||||||
vim.cmd(":wincmd =")
|
vim.cmd(":wincmd =")
|
||||||
end
|
end
|
||||||
@ -471,13 +472,13 @@ function View:set_current_win(callsite)
|
|||||||
log.line("dev", "View:set_current_win(%-20.20s) t%d w%3s->w%3s %s",
|
log.line("dev", "View:set_current_win(%-20.20s) t%d w%3s->w%3s %s",
|
||||||
callsite,
|
callsite,
|
||||||
current_tab,
|
current_tab,
|
||||||
globals.TABPAGES[current_tab].winnr,
|
globals.TABPAGES[current_tab].winid,
|
||||||
current_win,
|
current_win,
|
||||||
(globals.TABPAGES[current_tab].winnr == current_win) and "" or "MISMATCH"
|
(globals.TABPAGES[current_tab].winid == current_win) and "" or "MISMATCH"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
globals.TABPAGES[current_tab].winnr = current_win
|
globals.TABPAGES[current_tab].winid = current_win
|
||||||
end
|
end
|
||||||
|
|
||||||
---Open the tree in the a window
|
---Open the tree in the a window
|
||||||
@ -505,7 +506,7 @@ function View:abandon_current_window()
|
|||||||
if self.explorer.opts.experimental.multi_instance then
|
if self.explorer.opts.experimental.multi_instance then
|
||||||
log.line("dev", "View:abandon_current_window() t%d w%s b%s member b%s %s",
|
log.line("dev", "View:abandon_current_window() t%d w%s b%s member b%s %s",
|
||||||
tab,
|
tab,
|
||||||
globals.TABPAGES[tab] and globals.TABPAGES[tab].winnr or nil,
|
globals.TABPAGES[tab] and globals.TABPAGES[tab].winid or nil,
|
||||||
globals.BUFNR_PER_TAB[tab],
|
globals.BUFNR_PER_TAB[tab],
|
||||||
self.bufnr_by_tab[tab],
|
self.bufnr_by_tab[tab],
|
||||||
(globals.BUFNR_PER_TAB[tab] == self.bufnr_by_tab[tab]) and "" or "MISMATCH")
|
(globals.BUFNR_PER_TAB[tab] == self.bufnr_by_tab[tab]) and "" or "MISMATCH")
|
||||||
@ -517,7 +518,7 @@ function View:abandon_current_window()
|
|||||||
|
|
||||||
globals.BUFNR_PER_TAB[tab] = nil
|
globals.BUFNR_PER_TAB[tab] = nil
|
||||||
if globals.TABPAGES[tab] then
|
if globals.TABPAGES[tab] then
|
||||||
globals.TABPAGES[tab].winnr = nil
|
globals.TABPAGES[tab].winid = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -528,7 +529,7 @@ function View:abandon_all_windows(callsite)
|
|||||||
log.line("dev", "View:abandon_all_windows(%-20.20s) t%d w%s b%s member b%s %s",
|
log.line("dev", "View:abandon_all_windows(%-20.20s) t%d w%s b%s member b%s %s",
|
||||||
callsite,
|
callsite,
|
||||||
tab,
|
tab,
|
||||||
globals.TABPAGES and globals.TABPAGES.winnr or nil,
|
globals.TABPAGES and globals.TABPAGES.winid or nil,
|
||||||
globals.BUFNR_PER_TAB[tab],
|
globals.BUFNR_PER_TAB[tab],
|
||||||
self.bufnr_by_tab[tab],
|
self.bufnr_by_tab[tab],
|
||||||
(globals.BUFNR_PER_TAB[tab] == self.bufnr_by_tab[tab]) and "" or "MISMATCH")
|
(globals.BUFNR_PER_TAB[tab] == self.bufnr_by_tab[tab]) and "" or "MISMATCH")
|
||||||
@ -538,7 +539,7 @@ function View:abandon_all_windows(callsite)
|
|||||||
|
|
||||||
globals.BUFNR_PER_TAB[tab] = nil
|
globals.BUFNR_PER_TAB[tab] = nil
|
||||||
if globals.TABPAGES[tab] then
|
if globals.TABPAGES[tab] then
|
||||||
globals.TABPAGES[tab].winnr = nil
|
globals.TABPAGES[tab].winid = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -550,38 +551,39 @@ function View:is_visible(opts)
|
|||||||
if globals.TABPAGES[opts.tabpage] == nil then
|
if globals.TABPAGES[opts.tabpage] == nil then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local winnr = globals.TABPAGES[opts.tabpage].winnr
|
local winid = globals.TABPAGES[opts.tabpage].winid
|
||||||
return winnr and vim.api.nvim_win_is_valid(winnr)
|
return winid and vim.api.nvim_win_is_valid(winid)
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts and opts.any_tabpage then
|
if opts and opts.any_tabpage then
|
||||||
for _, v in pairs(globals.TABPAGES) do
|
for _, v in pairs(globals.TABPAGES) do
|
||||||
if v.winnr and vim.api.nvim_win_is_valid(v.winnr) then
|
if v.winid and vim.api.nvim_win_is_valid(v.winid) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return self:get_winnr(nil, "View:is_visible1") ~= nil and vim.api.nvim_win_is_valid(self:get_winnr(nil, "View:is_visible2") or 0)
|
local winid = self:get_winid(nil, "View:is_visible")
|
||||||
|
return winid ~= nil and vim.api.nvim_win_is_valid(winid or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts table|nil
|
---@param opts table|nil
|
||||||
function View:set_cursor(opts)
|
function View:set_cursor(opts)
|
||||||
if self:is_visible() then
|
if self:is_visible() then
|
||||||
pcall(vim.api.nvim_win_set_cursor, self:get_winnr(nil, "View:set_cursor"), opts)
|
pcall(vim.api.nvim_win_set_cursor, self:get_winid(nil, "View:set_cursor"), opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param winnr number|nil
|
---@param winid number|nil
|
||||||
---@param open_if_closed boolean|nil
|
---@param open_if_closed boolean|nil
|
||||||
function View:focus(winnr, open_if_closed)
|
function View:focus(winid, open_if_closed)
|
||||||
local wnr = winnr or self:get_winnr(nil, "View:focus1")
|
local wnr = winid or self:get_winid(nil, "View:focus1")
|
||||||
|
|
||||||
if vim.api.nvim_win_get_tabpage(wnr or 0) ~= vim.api.nvim_win_get_tabpage(0) then
|
if vim.api.nvim_win_get_tabpage(wnr or 0) ~= vim.api.nvim_win_get_tabpage(0) then
|
||||||
self:close(nil, "View:focus")
|
self:close(nil, "View:focus")
|
||||||
self:open()
|
self:open()
|
||||||
wnr = self:get_winnr(nil, "View:focus2")
|
wnr = self:get_winid(nil, "View:focus2")
|
||||||
elseif open_if_closed and not self:is_visible() then
|
elseif open_if_closed and not self:is_visible() then
|
||||||
self:open()
|
self:open()
|
||||||
end
|
end
|
||||||
@ -593,14 +595,14 @@ end
|
|||||||
|
|
||||||
--- Retrieve the winid of the open tree.
|
--- Retrieve the winid of the open tree.
|
||||||
---@param opts ApiTreeWinIdOpts|nil
|
---@param opts ApiTreeWinIdOpts|nil
|
||||||
---@return number|nil winid unlike get_winnr(), this returns nil if the nvim-tree window is not visible
|
---@return number|nil winid unlike get_winid(), this returns nil if the nvim-tree window is not visible
|
||||||
function View:api_winid(opts)
|
function View:api_winid(opts)
|
||||||
local tabpage = opts and opts.tabpage
|
local tabpage = opts and opts.tabpage
|
||||||
if tabpage == 0 then
|
if tabpage == 0 then
|
||||||
tabpage = vim.api.nvim_get_current_tabpage()
|
tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
end
|
end
|
||||||
if self:is_visible({ tabpage = tabpage }) then
|
if self:is_visible({ tabpage = tabpage }) then
|
||||||
return self:get_winnr(tabpage, "View:winid")
|
return self:get_winid(tabpage, "View:winid")
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -637,7 +639,7 @@ end
|
|||||||
---@param tabpage number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
|
---@param tabpage number|nil (optional) the number of the chosen tabpage. Defaults to current tabpage.
|
||||||
---@param callsite string
|
---@param callsite string
|
||||||
---@return number|nil
|
---@return number|nil
|
||||||
function View:get_winnr(tabpage, callsite)
|
function View:get_winid(tabpage, callsite)
|
||||||
local tabid = tabpage or vim.api.nvim_get_current_tabpage()
|
local tabid = tabpage or vim.api.nvim_get_current_tabpage()
|
||||||
local tabinfo = globals.TABPAGES[tabid]
|
local tabinfo = globals.TABPAGES[tabid]
|
||||||
local tabinfo_winid = nil
|
local tabinfo_winid = nil
|
||||||
@ -646,21 +648,21 @@ function View:get_winnr(tabpage, callsite)
|
|||||||
local msg_fault = ""
|
local msg_fault = ""
|
||||||
if not tabinfo then
|
if not tabinfo then
|
||||||
msg_fault = "no tabinfo"
|
msg_fault = "no tabinfo"
|
||||||
elseif not tabinfo.winnr then
|
elseif not tabinfo.winid then
|
||||||
msg_fault = "no tabinfo.winnr"
|
msg_fault = "no tabinfo.winid"
|
||||||
elseif not vim.api.nvim_win_is_valid(tabinfo.winnr) then
|
elseif not vim.api.nvim_win_is_valid(tabinfo.winid) then
|
||||||
msg_fault = string.format("invalid tabinfo.winnr %d", tabinfo.winnr)
|
msg_fault = string.format("invalid tabinfo.winid %d", tabinfo.winid)
|
||||||
else
|
else
|
||||||
tabinfo_winid = tabinfo.winnr
|
tabinfo_winid = tabinfo.winid
|
||||||
end
|
end
|
||||||
|
|
||||||
local winid = self:winid(tabid, "View:get_winnr")
|
local winid = self:winid(tabid, "View:get_winid")
|
||||||
|
|
||||||
if winid ~= tabinfo_winid then
|
if winid ~= tabinfo_winid then
|
||||||
msg_fault = "MISMATCH"
|
msg_fault = "MISMATCH"
|
||||||
end
|
end
|
||||||
|
|
||||||
local msg = string.format("View:get_winnr(%3s, %-20.20s) globals.TABPAGES[%s].winnr=w%s view.winid(%s)=w%s %s",
|
local msg = string.format("View:get_winid(%3s, %-20.20s) globals.TABPAGES[%s].winid=w%s view.winid(%s)=w%s %s",
|
||||||
tabpage,
|
tabpage,
|
||||||
callsite,
|
callsite,
|
||||||
tabid, tabinfo_winid,
|
tabid, tabinfo_winid,
|
||||||
@ -675,8 +677,9 @@ function View:get_winnr(tabpage, callsite)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tabinfo and tabinfo.winnr and vim.api.nvim_win_is_valid(tabinfo.winnr) then
|
-- legacy codepath
|
||||||
return tabinfo.winnr
|
if tabinfo and tabinfo.winid and vim.api.nvim_win_is_valid(tabinfo.winid) then
|
||||||
|
return tabinfo.winid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -703,7 +706,7 @@ function View:get_bufnr(callsite)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function View:prevent_buffer_override()
|
function View:prevent_buffer_override()
|
||||||
local view_winnr = self:get_winnr(nil, "View:prevent_buffer_override")
|
local view_winid = self:get_winid(nil, "View:prevent_buffer_override")
|
||||||
local view_bufnr = self:get_bufnr("View:prevent_buffer_override")
|
local view_bufnr = self:get_bufnr("View:prevent_buffer_override")
|
||||||
|
|
||||||
-- need to schedule to let the new buffer populate the window
|
-- need to schedule to let the new buffer populate the window
|
||||||
@ -717,9 +720,9 @@ function View:prevent_buffer_override()
|
|||||||
|
|
||||||
if not bufname:match("NvimTree") then
|
if not bufname:match("NvimTree") then
|
||||||
for i, tabpage in ipairs(globals.TABPAGES) do
|
for i, tabpage in ipairs(globals.TABPAGES) do
|
||||||
if tabpage.winnr == view_winnr then
|
if tabpage.winid == view_winid then
|
||||||
if self.explorer.opts.experimental.multi_instance then
|
if self.explorer.opts.experimental.multi_instance then
|
||||||
log.line("dev", "View:prevent_buffer_override() t%d w%d clearing", i, view_winnr)
|
log.line("dev", "View:prevent_buffer_override() t%d w%d clearing", i, view_winid)
|
||||||
end
|
end
|
||||||
|
|
||||||
globals.TABPAGES[i] = nil
|
globals.TABPAGES[i] = nil
|
||||||
@ -727,7 +730,7 @@ function View:prevent_buffer_override()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if curwin ~= view_winnr or bufname == "" or curbuf == view_bufnr then
|
if curwin ~= view_winid or bufname == "" or curbuf == view_bufnr then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -762,9 +765,9 @@ end
|
|||||||
|
|
||||||
-- used on ColorScheme event
|
-- used on ColorScheme event
|
||||||
function View:reset_winhl()
|
function View:reset_winhl()
|
||||||
local winnr = self:get_winnr(nil, "View:reset_winhl1")
|
local winid = self:get_winid(nil, "View:reset_winhl1")
|
||||||
if winnr and vim.api.nvim_win_is_valid(winnr) then
|
if winid and vim.api.nvim_win_is_valid(winid) then
|
||||||
vim.wo[self:get_winnr(nil, "View:reset_winhl2")].winhl = appearance.WIN_HL
|
vim.wo[winid].winhl = appearance.WIN_HL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ function M.set_target_win()
|
|||||||
|
|
||||||
local id = vim.api.nvim_get_current_win()
|
local id = vim.api.nvim_get_current_win()
|
||||||
|
|
||||||
if explorer and id == explorer.view:get_winnr(nil, "lib.set_target_win") then
|
if explorer and id == explorer.view:get_winid(nil, "lib.set_target_win") then
|
||||||
M.target_winid = 0
|
M.target_winid = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -105,24 +105,25 @@ function Renderer:draw()
|
|||||||
if not bufnr or not vim.api.nvim_buf_is_loaded(bufnr) then
|
if not bufnr or not vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local winid = self.explorer.view:get_winid(nil, "Renderer:draw")
|
||||||
|
|
||||||
local profile = log.profile_start("draw")
|
local profile = log.profile_start("draw")
|
||||||
|
|
||||||
local cursor = vim.api.nvim_win_get_cursor(self.explorer.view:get_winnr(nil, "Renderer:draw1") or 0)
|
local cursor = vim.api.nvim_win_get_cursor(winid or 0)
|
||||||
|
|
||||||
local builder = Builder(self.explorer):build()
|
local builder = Builder(self.explorer):build()
|
||||||
|
|
||||||
self:_draw(bufnr, builder.lines, builder.hl_range_args, builder.signs, builder.extmarks, builder.virtual_lines)
|
self:_draw(bufnr, builder.lines, builder.hl_range_args, builder.signs, builder.extmarks, builder.virtual_lines)
|
||||||
|
|
||||||
if cursor and #builder.lines >= cursor[1] then
|
if cursor and #builder.lines >= cursor[1] then
|
||||||
vim.api.nvim_win_set_cursor(self.explorer.view:get_winnr(nil, "Renderer:draw2") or 0, cursor)
|
vim.api.nvim_win_set_cursor(winid or 0, cursor)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.explorer.view:grow_from_content()
|
self.explorer.view:grow_from_content()
|
||||||
|
|
||||||
log.profile_end(profile)
|
log.profile_end(profile)
|
||||||
|
|
||||||
events._dispatch_on_tree_rendered(bufnr, self.explorer.view:get_winnr(nil, "Renderer:draw3"))
|
events._dispatch_on_tree_rendered(bufnr, winid)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Renderer
|
return Renderer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user