Skip to content
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

change_root_to_node() does not work on files #2717

Open
BenjaminHao opened this issue Mar 19, 2024 · 1 comment
Open

change_root_to_node() does not work on files #2717

BenjaminHao opened this issue Mar 19, 2024 · 1 comment
Labels
bug Something isn't working PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated reproduced Issue confirmed

Comments

@BenjaminHao
Copy link

BenjaminHao commented Mar 19, 2024

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

@BenjaminHao BenjaminHao added the bug Something isn't working label Mar 19, 2024
@BenjaminHao BenjaminHao changed the title nvim-tree-api.tree.change_root_to_node() does not work on file tree.change_root_to_node() does not work on files Mar 19, 2024
@BenjaminHao BenjaminHao changed the title tree.change_root_to_node() does not work on files change_root_to_node() does not work on files Mar 19, 2024
@alex-courtis
Copy link
Member

Working as intended; change_root_to_node only functions for root and directory nodes.

Other functions such as paste do work on file nodes. This should be consistent. This can be classed as a bug fix.

Api.tree.change_root_to_node logic should be moved into actions.root.change_dir.fn

As usual, pull requests are most gratefully appreciated, see CONTRIBUTING.md

@alex-courtis alex-courtis added PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated reproduced Issue confirmed labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR please nvim-tree team does not have the bandwidth to implement; a PR will be gratefully appreciated reproduced Issue confirmed
Projects
None yet
Development

No branches or pull requests

2 participants