Skip to content

Commit 19ec054

Browse files
authored
Merge branch 'master' into ci-lua-language-server
2 parents 6a2422b + 05f55c1 commit 19ec054

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

doc/nvim-tree-lua.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ via |nvim-tree.on_attach| e.g. >
250250

251251
Open the tree if it is closed, and then focus on the tree.
252252

253-
See |nvim-tree-api.tree.focus()|
253+
See |nvim-tree-api.tree.open()|
254254

255-
Calls: `api.tree.focus()`
255+
Calls: `api.tree.open()`
256256

257257
*:NvimTreeRefresh*
258258

@@ -1587,6 +1587,7 @@ tree.close_in_all_tabs() *nvim-tree-api.tree.close_in_all_tabs()*
15871587

15881588
tree.focus() *nvim-tree-api.tree.focus()*
15891589
Focus the tree, opening it if necessary.
1590+
Retained for compatibility, use |tree.open()| with no arguments instead.
15901591

15911592
tree.reload() *nvim-tree-api.tree.reload()*
15921593
Refresh the tree. Does nothing if closed.

lua/nvim-tree.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ local git = require "nvim-tree.git"
1313
local filters = require "nvim-tree.explorer.filters"
1414
local modified = require "nvim-tree.modified"
1515
local find_file = require "nvim-tree.actions.tree.find-file"
16-
local open = require "nvim-tree.actions.tree.open"
1716
local events = require "nvim-tree.events"
1817
local notify = require "nvim-tree.notify"
1918

@@ -23,11 +22,6 @@ local M = {
2322
init_root = "",
2423
}
2524

26-
function M.focus()
27-
open.fn()
28-
view.focus()
29-
end
30-
3125
--- Update the tree root to a directory or the directory containing
3226
--- @param path string relative or absolute
3327
--- @param bufnr number|nil
@@ -758,7 +752,7 @@ function M.purge_all_state()
758752
view.abandon_all_windows()
759753
if core.get_explorer() ~= nil then
760754
git.purge_state()
761-
TreeExplorer = nil
755+
core.reset_explorer()
762756
end
763757
end
764758

lua/nvim-tree/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Api.tree.close_in_this_tab = wrap(require("nvim-tree.view").close_this_tab_only)
8686
Api.tree.close_in_all_tabs = wrap(require("nvim-tree.view").close_all_tabs)
8787

8888
Api.tree.focus = wrap(function()
89-
require("nvim-tree").focus()
89+
Api.tree.open()
9090
end)
9191

9292
Api.tree.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_explorer)

lua/nvim-tree/commands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ local CMDS = {
4848
bar = true,
4949
},
5050
command = function()
51-
api.tree.focus()
51+
api.tree.open()
5252
end,
5353
},
5454
{

lua/nvim-tree/core.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local log = require "nvim-tree.log"
66

77
local M = {}
88

9-
TreeExplorer = nil
9+
local TreeExplorer = nil
1010
local first_init_done = false
1111

1212
function M.init(foldername)
@@ -27,6 +27,10 @@ function M.get_explorer()
2727
return TreeExplorer
2828
end
2929

30+
function M.reset_explorer()
31+
TreeExplorer = nil
32+
end
33+
3034
function M.get_cwd()
3135
return TreeExplorer and TreeExplorer.absolute_path
3236
end

lua/nvim-tree/live-filter.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local function redraw()
1111
end
1212

1313
local function reset_filter(node_)
14-
node_ = node_ or TreeExplorer
14+
node_ = node_ or require("nvim-tree.core").get_explorer()
1515
Iterator.builder(node_.nodes)
1616
:hidden()
1717
:applier(function(node)
@@ -79,7 +79,7 @@ function M.apply_filter(node_)
7979
node.hidden = not (has_nodes or (ok and is_match))
8080
end
8181

82-
iterate(node_ or TreeExplorer)
82+
iterate(node_ or require("nvim-tree.core").get_explorer())
8383
end
8484

8585
local function record_char()

0 commit comments

Comments
 (0)