refactor: api and command focus call tree.open(), soft deprecate tree.focus()

This commit is contained in:
Alexander Courtis 2023-11-26 10:02:47 +11:00 committed by gegoune
parent 5e4475d8bf
commit d5cc938ab0
4 changed files with 5 additions and 10 deletions

View File

@ -250,9 +250,9 @@ via |nvim-tree.on_attach| e.g. >
Open the tree if it is closed, and then focus on the tree. Open the tree if it is closed, and then focus on the tree.
See |nvim-tree-api.tree.focus()| See |nvim-tree-api.tree.open()|
Calls: `api.tree.focus()` Calls: `api.tree.open()`
*:NvimTreeRefresh* *:NvimTreeRefresh*
@ -1587,6 +1587,7 @@ tree.close_in_all_tabs() *nvim-tree-api.tree.close_in_all_tabs()*
tree.focus() *nvim-tree-api.tree.focus()* tree.focus() *nvim-tree-api.tree.focus()*
Focus the tree, opening it if necessary. Focus the tree, opening it if necessary.
Retained for compatibility, use |tree.open()| with no arguments instead.
tree.reload() *nvim-tree-api.tree.reload()* tree.reload() *nvim-tree-api.tree.reload()*
Refresh the tree. Does nothing if closed. Refresh the tree. Does nothing if closed.

View File

@ -13,7 +13,6 @@ local git = require "nvim-tree.git"
local filters = require "nvim-tree.explorer.filters" local filters = require "nvim-tree.explorer.filters"
local modified = require "nvim-tree.modified" local modified = require "nvim-tree.modified"
local find_file = require "nvim-tree.actions.tree.find-file" local find_file = require "nvim-tree.actions.tree.find-file"
local open = require "nvim-tree.actions.tree.open"
local events = require "nvim-tree.events" local events = require "nvim-tree.events"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
@ -23,11 +22,6 @@ local M = {
init_root = "", init_root = "",
} }
function M.focus()
open.fn()
view.focus()
end
--- Update the tree root to a directory or the directory containing --- Update the tree root to a directory or the directory containing
--- @param path string relative or absolute --- @param path string relative or absolute
--- @param bufnr number|nil --- @param bufnr number|nil

View File

@ -86,7 +86,7 @@ Api.tree.close_in_this_tab = wrap(require("nvim-tree.view").close_this_tab_only)
Api.tree.close_in_all_tabs = wrap(require("nvim-tree.view").close_all_tabs) Api.tree.close_in_all_tabs = wrap(require("nvim-tree.view").close_all_tabs)
Api.tree.focus = wrap(function() Api.tree.focus = wrap(function()
require("nvim-tree").focus() Api.tree.open()
end) end)
Api.tree.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_explorer) Api.tree.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_explorer)

View File

@ -48,7 +48,7 @@ local CMDS = {
bar = true, bar = true,
}, },
command = function() command = function()
api.tree.focus() api.tree.open()
end, end,
}, },
{ {