File tree 3 files changed +7
-6
lines changed
3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ local function try_netrw_hijack(path)
94
94
local netrw = require (" neo-tree.setup.netrw" )
95
95
if netrw .get_hijack_behavior () ~= " disabled" then
96
96
vim .cmd (" silent! autocmd! FileExplorer *" )
97
- return netrw .hijack ()
97
+ return netrw .hijack (path )
98
98
end
99
99
return false
100
100
end
Original file line number Diff line number Diff line change @@ -23,17 +23,16 @@ M.get_hijack_behavior = function()
23
23
end
24
24
end
25
25
26
+ --- @param path string ? Path to hijack (sometimes bufname doesn ' t set in time)
26
27
--- @return boolean hijacked Whether the hijack was successful
27
- M .hijack = function ()
28
- local manager = require (" neo-tree.sources.manager" )
29
- local log = require (" neo-tree.log" )
28
+ M .hijack = function (path )
30
29
local hijack_behavior = M .get_hijack_behavior ()
31
30
if hijack_behavior == " disabled" then
32
31
return false
33
32
end
34
33
35
34
-- ensure this is a directory
36
- local bufname = vim .api .nvim_buf_get_name (0 )
35
+ local bufname = path or vim .api .nvim_buf_get_name (0 )
37
36
local stats = vim .loop .fs_stat (bufname )
38
37
if not stats then
39
38
return false
@@ -48,6 +47,8 @@ M.hijack = function()
48
47
local winid = vim .api .nvim_get_current_win ()
49
48
local dir_bufnr = vim .api .nvim_get_current_buf ()
50
49
50
+ local manager = require (" neo-tree.sources.manager" )
51
+ local log = require (" neo-tree.log" )
51
52
-- Now actually open the tree, with a very quick debounce because this may be
52
53
-- called multiple times in quick succession.
53
54
utils .debounce (" hijack_netrw_" .. winid , function ()
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ local function try_netrw_hijack(path)
25
25
local netrw = require (" neo-tree.setup.netrw" )
26
26
if netrw .get_hijack_behavior () ~= " disabled" then
27
27
vim .cmd (" silent! autocmd! FileExplorer *" )
28
- return netrw .hijack ()
28
+ return netrw .hijack (path )
29
29
end
30
30
return false
31
31
end
You can’t perform that action at this time.
0 commit comments