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

On Windows, the drive letter in server responsed file URIs are lowercase. #1770

Closed
jfcherng opened this issue Jun 30, 2021 · 5 comments · Fixed by #1771 or #1772
Closed

On Windows, the drive letter in server responsed file URIs are lowercase. #1770

jfcherng opened this issue Jun 30, 2021 · 5 comments · Fixed by #1771 or #1772

Comments

@jfcherng
Copy link
Contributor

jfcherng commented Jun 30, 2021

Describe the bug

I tried both intelephense and pyright, they both returned lowercased drive letter thus I suspect it's a standard. (or maybe VSCode's LSP lib does it)

bandicam.2021-06-30.20-32-59-335_x264.mp4

In "Goto Definition...", this causes ST to open a file whose drive letter is in lowercase. And that may cause various mysterious problem sometimes... Or maybe, this should be fixed in ST core.

To Reproduce
Steps to reproduce the behavior:

  1. Install LSP-intelephense with a Windows build ST
  2. Open a PHP project
  3. Make sure the definition file is not opened in a tab already
  4. Do "Goto Definition"
  5. The newly opened tab should have a lower drive letter

Expected behavior

The drive letter should be uppercase.

Environment (please complete the following information):

  • OS: Win10 21H1 x64
  • Sublime Text version: 4109
  • LSP version: 4070-1.6.1
  • Language servers used: intelephense, pyright

Additional context

This is a Windows-only issue as it's case-insensitive.

@rwols
Copy link
Member

rwols commented Jun 30, 2021

The drive letter should be uppercase.

Why?

@rchl rchl reopened this Jun 30, 2021
@jfcherng
Copy link
Contributor Author

jfcherng commented Jun 30, 2021

The drive letter should be uppercase.

Why?

Because (I think) it's Windows' default, unless the user somehow uses lowercase intentionally. Or LSP is able to tell which case is actually used.

@jwortmann
Copy link
Member

There is another problem with the lowercase drive letters when opening a file: even though Sublime highlights the correct file in the sidebar (if it is a file from an opened folder), it doesn't it doesn't show the git status in the status bar for files with lowercase drive letter (if it is part of a git repo). So we should normalize the drive letter to uppercase.

@jwortmann
Copy link
Member

Another thing that doesn't work as intended is the quick panel for "Find References" if "show_references_in_quick_panel" is true in LSP settings. It shows the full path, but without drive letter (i.e. starting with :). That seems to happen because os.path.commonprefix((pathname, base_dir)) called in location_to_human_readable is an empty string (base_dir has uppercase drive letter and pathname has lowercase drive letter). I already have a fix to normalize to uppercase drive letter in uri_to_filename in core/url.py (that function is marked as deprecated though).

And I think I've found another bug (?) in

re.sub(r"^([A-Z]):/", _lowercase_driveletter, path)

this line does nothing because the return value is not assigned to a variable (strings are immutable in Python afaik).

@jfcherng
Copy link
Contributor Author

jfcherng commented Jul 1, 2021

Awesome! Confirm fixed on my side as well. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants