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

fix(command): normalize reveal_file path argument #1402

Merged
merged 2 commits into from Mar 15, 2024

Conversation

Renerick
Copy link
Contributor

I found that when using neo-tree with project.nvim, when changing cwd via project selector, reveal argument doesn't work, the file is not focused upon opening the tree. Turns out, project.nvim normalizes disk names on Windows to lower case

https://github.com/ahmedkhalf/project.nvim/blob/8c6bad7d22eef1b71144b401c9f74ed01526a4fb/lua/project_nvim/utils/history.lua#L32-L34

As a result, switching directories via project.nvim on Windows results in all file paths having lower case drive letter

image

Meanwhile, neo-tree normalizes drive names to upper case

-- normalize the drive letter to uppercase
path = path:sub(1, 1):upper() .. path:sub(2)

But it doesn't do so for reveal_file argument. Since normalized file names are used as case sensitive ids, neo-tree is unable to find file to reveal and just does nothing.

The issue can be trivially reproduced by running :cd c:\[directory] with drive letter in lower case and trying to open neo-tree with reveal argument (or relative path in reveal_file argument).

This fix applies same normalization process to the input parameter, eliminating possible discrepancies.

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@cseickel cseickel merged commit 146445f into nvim-neo-tree:main Mar 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants