File tree 3 files changed +19
-2
lines changed
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,21 @@ M.setup = function(config)
259
259
end
260
260
local prior_type = vim .api .nvim_buf_get_option (prior_buf , " filetype" )
261
261
if prior_type == " neo-tree" and vim .bo .filetype ~= " neo-tree" then
262
- local bufname = vim .fn .bufname ()
262
+ local current_tabnr = vim .api .nvim_get_current_tabpage ()
263
+ local neo_tree_tabnr = vim .api .nvim_buf_get_var (prior_buf , " neo_tree_tabnr" )
264
+ if neo_tree_tabnr ~= current_tabnr then
265
+ -- This a new tab, so the alternate being neo-tree doesn't matter.
266
+ return
267
+ end
268
+ local neo_tree_winid = vim .api .nvim_buf_get_var (prior_buf , " neo_tree_winid" )
269
+ local current_winid = vim .api .nvim_get_current_win ()
270
+ if neo_tree_winid ~= current_winid then
271
+ -- This is not the neo-tree window, so the alternate being neo-tree doesn't matter.
272
+ return
273
+ end
274
+
275
+ local bufname = vim .api .nvim_buf_get_name (0 )
276
+ log .debug (" redirecting buffer " .. bufname .. " to new split" )
263
277
vim .cmd (" b#" )
264
278
-- Using schedule at this point fixes problem with syntax
265
279
-- highlighting in the buffer. I also prevents errors with diagnostics
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ M.show_filter = function(state, search_as_you_type)
40
40
fs .reset_search ()
41
41
else
42
42
state .search_pattern = value
43
- fs .refresh (function ()
43
+ manager .refresh (" filesystem " , function ()
44
44
-- focus first file
45
45
local nodes = renderer .get_all_visible_nodes (state .tree )
46
46
for _ , node in ipairs (nodes ) do
Original file line number Diff line number Diff line change @@ -429,6 +429,9 @@ local create_window = function(state)
429
429
if type (state .bufnr ) == " number" then
430
430
local bufname = string.format (" neo-tree %s [%s]" , state .name , state .tabnr )
431
431
vim .api .nvim_buf_set_name (state .bufnr , bufname )
432
+ vim .api .nvim_buf_set_var (state .bufnr , " neo_tree_source" , state .name )
433
+ vim .api .nvim_buf_set_var (state .bufnr , " neo_tree_winid" , state .winid )
434
+ vim .api .nvim_buf_set_var (state .bufnr , " neo_tree_tabnr" , state .tabnr )
432
435
end
433
436
434
437
win :on ({ " BufDelete" }, function ()
You can’t perform that action at this time.
0 commit comments