nvim-tree / nvim-tree/nvim-tree.lua
change_root_to_node() does not work on files
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 8.6k
- Forks
- 639
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 2
Description
Description
According to the help file, change_root_to_node will change the tree's root to a folder node or the parent of a file node.
However, it only works when I put cursor on a folder. If the cursor is on a file, it does not set the tree's root to its current folder.
Neovim version
NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320
Operating system and version
Windows 11
Windows variant
No response
nvim-tree version
master branch
Clean room replication
No need config
default keymap is <C-]>
Steps to reproduce
- nvim -nu /tmp/nvt-min.lua
- :NvimTreeOpen
- Press <-> to go up
- select any file
- Press <C-]> to change root to node
Expected behavior
root directory changes to the file's folder
Actual behavior
Nothing happens
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the default <C-]> mapping to the change_root_to_node() handler and reproduce the behavior with the minimal configuration described. Check how the handler resolves folder and file nodes; done means selecting a file changes the tree root to its parent folder, with the existing reproduction steps confirming the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100