Skip to content

fix: use canonical path in windows #977

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

Merged
merged 3 commits into from
Feb 15, 2022

Conversation

younger-1
Copy link
Contributor

This fixes #953.

Relative upstream issue: neovim/neovim#16331

@younger-1 younger-1 changed the title fix: use fs_realpath to get the filepath fix: use canonical path in windows Feb 14, 2022
@younger-1
Copy link
Contributor Author

younger-1 commented Feb 14, 2022

When I simply use fs_realpath of libuv, the bug of #953 went away but it caused new error:

Error detected while processing BufEnter Autocommands for "*":
E5108: Error executing lua ...ata\site\pack\packer\opt\nvim-tree.lua/lua/nvim-tree.lua:164: bad argument #1 to 'fs_stat' (string expected, got nil)
stack traceback:
        [C]: in function 'fs_stat'
        ...ata\site\pack\packer\opt\nvim-tree.lua/lua/nvim-tree.lua:164: in function 'is_file_readable'
        ...ata\site\pack\packer\opt\nvim-tree.lua/lua/nvim-tree.lua:192: in function 'find_file'
        [string ":lua"]:1: in main chunk

It seems that the result of luv.fs_realpath(filepath) is nil which convinced me fs_realpath is async.
But it should be sync in this case, according to the doc of libuv...
https://github.com/kyazdani42/nvim-tree.lua/blob/9ad827789f8b01587dea5dd2d629206c847a26e2/lua/nvim-tree.lua#L191-L194

https://github.com/luvit/luv/blob/9d602ab12654d3adb53f34457390f534eb85f5d6/docs.md?plain=1#L2891-L2897

### `uv.fs_realpath(path, [callback])`

**Parameters:**
- `path`: `string`
- `callback`: `callable` (async version) or `nil` (sync version)
  - `err`: `nil` or `string`
  - `path`: `string` or `nil`

Could anyone knows this give some tips?

@kyazdani42
Copy link
Member

could you rebase :) ?

@kyazdani42
Copy link
Member

Also i'm not sure for your issue with realpath, might be related to windows somehow ?

@younger-1
Copy link
Contributor Author

could you rebase :) ?

Done

@kyazdani42 kyazdani42 merged commit 121f5c9 into nvim-tree:master Feb 15, 2022
@kyazdani42
Copy link
Member

thanks :)

Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this pull request Oct 11, 2022
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.

[Bug] NvimTreeFindFile do not reveal file in tree
2 participants