@@ -113,17 +113,11 @@ M.close = function(state, focus_prior_window)
113113 if focus_prior_window == nil then
114114 focus_prior_window = true
115115 end
116- if not M .window_exists (state ) then
117- return false
118- end
119116
120- log .debug (" Closing window, but saving position first." )
121- M .position .save (state , true )
122- local closed = false
123- -- if bufnr is different then we expect, then it was taken over by
124- -- another buffer, so we can't delete it now
125- if vim .api .nvim_win_get_buf (state .winid ) == state .bufnr then
126- closed = true
117+ local window_existed = M .window_exists (state )
118+ if window_existed then
119+ log .debug (" Closing window, but saving position first." )
120+ M .position .save (state , true )
127121 if state .current_position == " current" then
128122 -- we are going to hide the buffer instead of closing the window
129123 local new_buf = vim .fn .bufnr (" #" )
@@ -155,8 +149,8 @@ M.close = function(state, focus_prior_window)
155149 events .fire_event (events .NEO_TREE_WINDOW_AFTER_CLOSE , args )
156150 end
157151 end
158-
159152 state .winid = nil
153+
160154 local bufnr = state .bufnr or 0
161155 if bufnr > 0 and vim .api .nvim_buf_is_valid (bufnr ) then
162156 state .bufnr = nil
@@ -167,7 +161,7 @@ M.close = function(state, focus_prior_window)
167161 end )()
168162 end
169163 end
170- return closed
164+ return window_existed
171165end
172166
173167M .close_floating_window = function (source_name )
@@ -1258,7 +1252,6 @@ M.window_exists = function(state)
12581252
12591253 local buf_position = vim .b [bufnr ].neo_tree_position
12601254 if buf_position ~= position then
1261- log .trace (" pos won't work" )
12621255 return false
12631256 end
12641257 return window_exists
0 commit comments