Skip to content

Commit d5cc938

Browse files
alex-courtisgegoune
authored andcommitted
refactor: api and command focus call tree.open(), soft deprecate tree.focus()
1 parent 5e4475d commit d5cc938

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
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: 0 additions & 6 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

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
{

0 commit comments

Comments
 (0)