Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ via |nvim-tree.on_attach| e.g. >

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*

Expand Down Expand Up @@ -1587,6 +1587,7 @@ tree.close_in_all_tabs() *nvim-tree-api.tree.close_in_all_tabs()*

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

tree.reload() *nvim-tree-api.tree.reload()*
Refresh the tree. Does nothing if closed.
Expand Down
6 changes: 0 additions & 6 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ local git = require "nvim-tree.git"
local filters = require "nvim-tree.explorer.filters"
local modified = require "nvim-tree.modified"
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 notify = require "nvim-tree.notify"

Expand All @@ -23,11 +22,6 @@ local M = {
init_root = "",
}

function M.focus()
open.fn()
view.focus()
end

--- Update the tree root to a directory or the directory containing
--- @param path string relative or absolute
--- @param bufnr number|nil
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.focus = wrap(function()
require("nvim-tree").focus()
Api.tree.open()
end)

Api.tree.reload = wrap(require("nvim-tree.actions.reloaders.reloaders").reload_explorer)
Expand Down
2 changes: 1 addition & 1 deletion lua/nvim-tree/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ local CMDS = {
bar = true,
},
command = function()
api.tree.focus()
api.tree.open()
end,
},
{
Expand Down