Coc.nvim: Windows: <Plug>(coc-definition) may result in opening buffer with differently cased drive letter

Created on 9 Oct 2019  Â·  7Comments  Â·  Source: neoclide/coc.nvim

Result from CocInfo

vim version: NVIM v0.4.2
node version: v11.13.0
coc.nvim version: 0.0.74-bc017b02e6
term: vtpcon
platform: win32

Describe the bug

If using <Plug>coc-definition on a symbol with the definition in a different file than the current one, the opened file's path will always have a lower cased drive letter even if the current working directory uses an upper cased drive letter. Due to this discrepancy, the newly opened buffer will not be considered a child of the current working directory. This can disrupt a lot of functionality from other plugins that rely on this behavior.

Please make the drive letters for files opened in this manner use the same case as the drive letter in the current working directory (obviously, this would only apply to Windows).

Reproduce the bug

  • mini.vim:
    vim set nocompatible set runtimepath^=/path/to/coc.nvim " Make sure to replace this for your system filetype plugin indent on syntax on set hidden nmap <silent> gd <Plug>(coc-definition)
  • test.py:
    py from func import * foo()
  • func.py:
    py def foo(): print('Hello World')
  • Start Neovim with command: nvim -u mini.vim
  • Install coc-python: :CocInstall coc-python
  • Restart Neovim, just in case
  • Open test.py: nvim -u mini.vim test.py
  • Enter :pwd and note the result. For me, it was C:/projects/tmp. Note the capital C.
  • Place cursor on foo()
  • Press gd
  • func.py should now be opened. Press Ctrl-G and note the result. For me, this was c:/projects/tmp/func.py. Note the lowercase c.
bug help wanted

Most helpful comment

Seems like the issue is here. According to the vscode-uri documentation, fsPath normalizes Windows drive letters to lower case.

All 7 comments

I noticed this issue was transferred from the main coc repo and I wanted to point out that this problem is not limited to Python. I have reproduced the issue with C++ using clangd and ccls as well. coc-python was used in this example since it was the simplest way to provide reproduction steps. Sorry for not making that clear earlier.

Should be bug, but I don't have time to look into it for now.

Seems like the issue is here. According to the vscode-uri documentation, fsPath normalizes Windows drive letters to lower case.

Unfortunately I still see this problem in windows, when I do go-to-reference and go-to-definition. Fixing this will improve usability in windows significantly.

I haven't tried go to reference, but go to definition worked. How did you update coc? Did you run yarn install?

It was my bad. I was using the release branch which didn't have the commit. It works on master. Thank you!

Release branch has that commit, could be failure on update.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tom-james-watson picture tom-james-watson  Â·  3Comments

czepluch picture czepluch  Â·  3Comments

MaskRay picture MaskRay  Â·  3Comments

npearson72 picture npearson72  Â·  3Comments

marene picture marene  Â·  3Comments