Description
Description
I think there's a bug when creating a new directory. It seems like the cursor does not position itself over this directory as it does with newly created files. Demonstration:
The cursor does position itself over the created file:
https://user-images.githubusercontent.com/47466248/184143644-4364439b-ad50-48ed-a478-682ef23f813a.mp4
It doesn't after creating a directory:
https://user-images.githubusercontent.com/47466248/184144081-151dc343-5f0c-4691-8cd3-22e32cc62886.mp4
At first I thought maybe this was intended to work with files only, but I inspected the source code a bit and found that it's a single function fs.create-file
what handles the creation for both types of nodes and that at the end of this function there is a deferred callback that handles the focusing of this new node.
If I call this util function manually, it does work:
https://user-images.githubusercontent.com/47466248/184145203-33f23899-a777-428e-9f81-db0d68e54a68.mp4
Possible Bug Source
Because it did work with files out-of-the-box and also worked with folders manually, I ended up finding out that the problem is with the formatting of the path for files on the create-file
function and the utils.focus_file
function. The later one doesn't play work with paths that have a "/" at the end:
focus_file_with_trailing_slash.mp4
And the new_file_path
path that fs.create-file
returns is indeed formatted with a trailing slash.
If this is actually a bug, I would like to try to solve it, don't know if I actually have to ask for this or just open a PR :), but I've never contributed to OS and this would be my first time so I guess I just have to follow the guidelines and open a PR?
Neovim version
NVIM v0.8.0-dev-798-ge6680ea7c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Operating system and version
Linux 5.18.16-arch1-1
nvim-tree version
Minimal config
require("nvim-tree").setup {}
Steps to reproduce
- Just create a folder on the explorer by creating a new file and appending "/" to the name.
Expected behavior
The cursor should keep focus on the directory, as it does with files. It's actually a bug with utils.focus_file()
method, so this isn't applicable only to newly created directories.
Actual behavior
The cursor returns to the top of the explorer buffer.