nvim-tree / nvim-tree/nvim-tree.lua

change_root_to_node() does not work on files

Open
#2,717 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug PR please reproduced
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
  1. nvim -nu /tmp/nvt-min.lua
  2. :NvimTreeOpen
  3. Press <-> to go up
  4. select any file
  5. Press <C-]> to change root to node
Expected behavior

root directory changes to the file's folder

Actual behavior

Nothing happens

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.