Skip to content

Commit 0e860cf

Browse files
author
xundaoxd
authored
Merge branch 'master' into master
2 parents b50889d + 0a89dcb commit 0e860cf

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

doc/nvim-tree-lua.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ applying configuration.
494494
},
495495
open_file = {
496496
quit_on_open = false,
497+
eject = true,
497498
resize_window = true,
498499
window_picker = {
499500
enable = true,
@@ -1148,7 +1149,6 @@ Configuration options for trashing.
11481149
*nvim-tree.trash.cmd*
11491150
The command used to trash items (must be installed on your system).
11501151
The default is shipped with glib2 which is a common linux package.
1151-
Only available for UNIX.
11521152
Type: `string`, Default: `"gio trash"`
11531153

11541154
*nvim-tree.actions*
@@ -1204,9 +1204,12 @@ Configuration for various actions.
12041204

12051205
*nvim-tree.actions.open_file.quit_on_open*
12061206
Closes the explorer when opening a file.
1207-
It will also disable preventing a buffer overriding the tree.
12081207
Type: `boolean`, Default: `false`
12091208

1209+
*nvim-tree.actions.open_file.eject*
1210+
Prevent new opened file from opening in the same window as the tree.
1211+
Type: `boolean`, Default: `true`
1212+
12101213
*nvim-tree.actions.open_file.resize_window* (previously `view.auto_resize`)
12111214
Resizes the tree when opening a file.
12121215
Type: `boolean`, Default: `true`
@@ -2293,7 +2296,7 @@ macOS
22932296
system.
22942297

22952298
Windows WSL and PowerShell
2296-
- Trash is unavailable
2299+
- Trash is synchronized
22972300
- Executable file detection is disabled as this is non-performant and can
22982301
freeze nvim
22992302
- Some filesystem watcher error related to permissions will not be reported

lua/nvim-tree.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,13 @@ local function setup_autocommands(opts)
196196
create_nvim_tree_autocmd("BufWipeout", {
197197
pattern = "NvimTree_*",
198198
callback = function()
199-
if utils.is_nvim_tree_buf(0) then
199+
if not utils.is_nvim_tree_buf(0) then
200+
return
201+
end
202+
if opts.actions.open_file.eject then
200203
view._prevent_buffer_override()
204+
else
205+
view.abandon_current_window()
201206
end
202207
end,
203208
})
@@ -545,6 +550,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
545550
},
546551
open_file = {
547552
quit_on_open = false,
553+
eject = true,
548554
resize_window = true,
549555
window_picker = {
550556
enable = true,

lua/nvim-tree/actions/fs/trash.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function M.fn(node)
3030
end
3131

3232
-- configs
33-
if utils.is_unix then
33+
if utils.is_unix or utils.is_windows then
3434
if M.config.trash.cmd == nil then
3535
M.config.trash.cmd = "trash"
3636
end
@@ -55,11 +55,15 @@ function M.fn(node)
5555

5656
-- trashes a path (file or folder)
5757
local function trash_path(on_exit)
58-
vim.fn.jobstart(M.config.trash.cmd .. ' "' .. node.absolute_path .. '"', {
59-
detach = true,
58+
local need_sync_wait = utils.is_windows
59+
local job = vim.fn.jobstart(M.config.trash.cmd .. ' "' .. node.absolute_path .. '"', {
60+
detach = not need_sync_wait,
6061
on_exit = on_exit,
6162
on_stderr = on_stderr,
6263
})
64+
if need_sync_wait then
65+
vim.fn.jobwait { job }
66+
end
6367
end
6468

6569
local function do_trash()

lua/nvim-tree/explorer/node.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function M.get_git_status(node)
111111
end
112112

113113
function M.is_git_ignored(node)
114-
return node.git_status and node.git_status.file == "!!"
114+
return node and node.git_status and node.git_status.file == "!!"
115115
end
116116

117117
function M.node_destroy(node)

lua/nvim-tree/explorer/reload.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ end
3030

3131
local function update_parent_statuses(node, project, root)
3232
while project and node and node.absolute_path ~= root do
33-
explorer_node.update_git_status(node, false, project)
33+
explorer_node.update_git_status(node, explorer_node.is_git_ignored(node.parent), project)
3434
node = node.parent
3535
end
3636
end

0 commit comments

Comments
 (0)