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

Use relative path to find file #837

Closed
kuznetsss opened this issue Dec 9, 2021 · 5 comments
Closed

Use relative path to find file #837

kuznetsss opened this issue Dec 9, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@kuznetsss
Copy link
Contributor

I think using absolute path in searching for file is wrong because there could be symlinks.

For example in my system I open file from home directory:
~$ nvim Documents/vimwiki/index.md
But Documents is symlink Documents -> /mnt/Data/home_user/Documents
So the real absolute file path is /mnt/Data/home_user/Documents/vimwiki/index.md which nvim-tree tries to find being in /home/user directory. So the file can't be found.

I think it would be better to search file by relative path from nvim's cwd.

@kyazdani42
Copy link
Member

you are correct, we should be searching by relative path. You could open a PR if i didn't fix this by the end of the day.

@kyazdani42 kyazdani42 added the bug Something isn't working label Dec 12, 2021
@alex-courtis
Copy link
Member

alex-courtis commented Mar 20, 2022

Current behaviour:

mkdir /tmp/root1
mkdir /tmp/root2
cd /tmp/root2
mkdir dir3
touch dir3/file31
cd /tmp/root1
mkdir dir1
mkdir dir2
touch file1
touch dir1/file11
cd /tmp/root1
ln -s /tmp/root2/dir3 dir31
ln -s ../root2/dir3 dir32
nvim -nu /tmp/nvt-min.lua

Success:
dir1/file11
dir31/file31
dir32/file31
dir1
dir2
dir31
dir32
file1

Fail:
file11
file31

It appears that the issues with the relative path of symlinks is resolved, be they absolute or relative. Search is successful for file11 and file31 if we C-] into dir1 dir31 or dir32 first.

@alex-courtis
Copy link
Member

alex-courtis commented Mar 20, 2022

This does highlight a problem, which might be in my understanding: we can only search for files/dirs which match a path under cwd, not for files/dirs of a name.

Proposal: search matches full file/dir names under cwd, as per :find behaviour.

PR #837

alex-courtis added a commit that referenced this issue Mar 20, 2022
@alex-courtis
Copy link
Member

There are still some lingering issues around symlinked rel vs absolute:

find-file absolute path: node will be opened, however it will not be focussed
find-file path relative to cwd: node will not be found

@alex-courtis
Copy link
Member

Resolved via #1092 #1107

kyazdani42 pushed a commit that referenced this issue Mar 26, 2022
Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this issue Oct 11, 2022
Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this issue Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants