Skip to content

Commit c46c921

Browse files
committed
Finish todos and add close_all_tabs
1 parent de12e39 commit c46c921

File tree

7 files changed

+14
-17
lines changed

7 files changed

+14
-17
lines changed

lua/nvim-tree.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ M.on_keypress = require("nvim-tree.actions.dispatch").dispatch
7070

7171
function M.toggle(find_file, no_focus, cwd, bang)
7272
if view.is_visible() then
73-
view.close() -- TODO Choose one
74-
-- view.close_this_tab_only() -- TODO Choose one
73+
view.close()
7574
else
7675
local previous_buf = vim.api.nvim_get_current_buf()
7776
M.open(cwd)
@@ -439,8 +438,7 @@ local function setup_autocommands(opts)
439438
pattern = "NvimTree_*",
440439
callback = function()
441440
if utils.is_nvim_tree_buf(0) then
442-
view.close() -- TODO Choose one
443-
-- view.close_this_tab_only() -- TODO Choose one
441+
view.close()
444442
end
445443
end,
446444
})
@@ -775,8 +773,7 @@ function M.setup(conf)
775773
end
776774

777775
if M.setup_called and view.is_visible() then
778-
view.close() -- TODO Choose one
779-
-- view.close_this_tab_only() -- TODO Choose one
776+
view.close_all_tabs()
780777
view.abandon_current_window()
781778
end
782779

lua/nvim-tree/actions/dispatch.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ local lib = require "nvim-tree.lib"
44
local M = {}
55

66
local Actions = {
7-
-- close = view.close(), -- TODO Choose one
8-
close = view.close_this_tab_only(), -- TODO Choose one
7+
close = view.close,
98

109
-- Tree modifiers
1110
collapse_all = require("nvim-tree.actions.tree-modifiers.collapse-all").fn,

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ end
143143

144144
local function open_file_in_tab(filename)
145145
if M.quit_on_open then
146-
view.close() -- TODO Choose one
147-
-- view.close_this_tab_only() -- TODO Choose one
146+
view.close()
148147
end
149148
vim.cmd("tabe " .. vim.fn.fnameescape(filename))
150149
end
@@ -307,8 +306,7 @@ function M.fn(mode, filename)
307306
end
308307

309308
if M.quit_on_open then
310-
view.close() -- TODO Choose one
311-
-- view.close_this_tab_only() -- TODO Choose one
309+
view.close()
312310
end
313311
end
314312

lua/nvim-tree/api.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ end
1818
Api.tree.open = require("nvim-tree").open
1919
Api.tree.toggle = require("nvim-tree").toggle
2020
Api.tree.close = require("nvim-tree.view").close
21-
Api.tree.close_this_tab = require("nvim-tree.view").close_this_tab_only
21+
Api.tree.close_in_this_tab = require("nvim-tree.view").close_this_tab_only
22+
Api.tree.close_in_all_tabs = require("nvim-tree.view").close_all_tabs
2223
Api.tree.focus = require("nvim-tree").focus
2324
Api.tree.reload = require("nvim-tree.actions.reloaders.reloaders").reload_explorer
2425
Api.tree.change_root = require("nvim-tree").change_dir

lua/nvim-tree/lib.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ function M.open(cwd)
117117
core.init(cwd or vim.loop.cwd())
118118
end
119119
if should_hijack_current_buf() then
120-
-- view.close() -- TODO Choose one
121-
view.close_this_tab_only() -- TODO Choose one
120+
view.close_this_tab_only()
122121
view.open_in_current_win()
123122
renderer.draw()
124123
else

lua/nvim-tree/live-filter.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ local function remove_overlay()
3131
group = vim.api.nvim_create_augroup("NvimTree", { clear = false }),
3232
callback = function()
3333
if utils.is_nvim_tree_buf(0) then
34-
view.close() -- TODO Choose one
35-
-- view.close_this_tab_only() -- TODO Choose one
34+
view.close()
3635
end
3736
end,
3837
})

lua/nvim-tree/view.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ function M.close_this_tab_only()
218218
close(false)
219219
end
220220

221+
function M.close_all_tabs()
222+
close(true)
223+
end
224+
221225
function M.close()
222226
close(M.View.open_on_tab)
223227
end

0 commit comments

Comments
 (0)