@@ -34,13 +34,13 @@ local View = Class:extend()
3434function View :new (args )
3535 args .explorer :log_new (" View" )
3636
37- self .explorer = args .explorer
38- self .adaptive_size = false
39- self .side = (self .explorer .opts .view .side == " right" ) and " right" or " left"
40- self .live_filter = { prev_focused_node = nil , }
41- self .bufnr_by_tabid = {}
37+ self .explorer = args .explorer
38+ self .adaptive_size = false
39+ self .side = (self .explorer .opts .view .side == " right" ) and " right" or " left"
40+ self .live_filter = { prev_focused_node = nil , }
41+ self .bufnr_by_tabid = {}
4242
43- self .winopts = {
43+ self .winopts = {
4444 relativenumber = self .explorer .opts .view .relativenumber ,
4545 number = self .explorer .opts .view .number ,
4646 list = false ,
@@ -137,7 +137,9 @@ local move_tbl = {
137137
138138--- @private
139139function View :set_window_options_and_buffer ()
140- pcall (vim .api .nvim_command , " buffer " .. self :get_bufnr_internal ())
140+ if not pcall (vim .api .nvim_command , " buffer " .. self .bufnr ) then
141+ return
142+ end
141143
142144 if vim .fn .has (" nvim-0.10" ) == 1 then
143145 local eventignore = vim .api .nvim_get_option_value (" eventignore" , {})
298300--- @private
299301function View :grow ()
300302 local starts_at = self :is_root_folder_visible (require (" nvim-tree.core" ).get_cwd ()) and 1 or 0
301- local lines = vim .api .nvim_buf_get_lines (self : get_bufnr_internal () , starts_at , - 1 , false )
303+ local lines = vim .api .nvim_buf_get_lines (self . bufnr , starts_at , - 1 , false )
302304 -- number of columns of right-padding to indicate end of path
303305 local padding = self :get_size (self .padding )
304306
@@ -322,7 +324,7 @@ function View:grow()
322324 for line_nr , l in pairs (lines ) do
323325 local count = vim .fn .strchars (l )
324326 -- also add space for right-aligned icons
325- local extmarks = vim .api .nvim_buf_get_extmarks (self : get_bufnr_internal () , ns_id , { line_nr , 0 }, { line_nr , - 1 }, { details = true })
327+ local extmarks = vim .api .nvim_buf_get_extmarks (self . bufnr , ns_id , { line_nr , 0 }, { line_nr , - 1 }, { details = true })
326328 count = count + utils .extmarks_length (extmarks )
327329 if resizing_width < count then
328330 resizing_width = count
@@ -540,16 +542,6 @@ function View:get_winid()
540542 return utils .first_window_containing_buf (self .bufnr )
541543end
542544
543- --- TODO this needs to be refactored away; it's private now to contain it
544- --- Returns the current nvim tree bufnr
545- --- @private
546- --- @return number
547- function View :get_bufnr_internal ()
548- local tab = vim .api .nvim_get_current_tabpage ()
549-
550- return self .bufnr_by_tabid [tab ]
551- end
552-
553545--- buffer for this view
554546--- @return integer ?
555547function View :get_bufnr ()
558550
559551function View :prevent_buffer_override ()
560552 local view_winid = self :get_winid_internal ()
561- local view_bufnr = self : get_bufnr_internal ()
553+ local view_bufnr = self . bufnr
562554
563555 -- need to schedule to let the new buffer populate the window
564556 -- because this event needs to be run on bufWipeout.
0 commit comments