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 WSL path URI decoding under Windows #1962

Merged
merged 3 commits into from
Apr 14, 2022

Conversation

jfcherng
Copy link
Contributor

@jfcherng jfcherng commented Apr 14, 2022

Python 3.3>>> from LSP.plugin.core.url import filename_to_uri, parse_uri, urlparse

Python 3.3>>> filename_to_uri('\\\\wsl$\\Ubuntu-20.04\\home\\jfcherng\\Desktop\\docs\\a.py')
'file://wsl%24/Ubuntu-20.04/home/jfcherng/Desktop/docs/a.py'
           
Python 3.3>>> parse_uri('file://wsl%24/Ubuntu-20.04/home/jfcherng/Desktop/docs/a.py')
('file', '\\\\wsl%24\\Ubuntu-20.04\\home\\jfcherng\\Desktop\\docs\\a.py')
                 ^^^ this is wrong. should be $

Python 3.3>>> urlparse('file://wsl%24/Ubuntu-20.04/home/jfcherng/Desktop/docs/a.py')
ParseResult(scheme='file', netloc='wsl%24', path='/Ubuntu-20.04/home/jfcherng/Desktop/docs/a.py', params='', query='', fragment='')
                                      ^^^ this is wrong. should be $

Notice that netloc is wsl%24 after urlparse(). We need to decoding that before doing "\\\\{}\\{}".format(netloc, path) just like what we do for path.

Related issue: https://discord.com/channels/280102180189634562/280157083356233728/963549081886666784

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
plugin/core/url.py Outdated Show resolved Hide resolved
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
Copy link
Member

@rwols rwols left a comment

Choose a reason for hiding this comment

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

Can you add a test for this so we don’t regress in the future? There are windows-specific tests that run in the CI

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@rwols rwols merged commit 74c5811 into sublimelsp:main Apr 14, 2022
@jfcherng jfcherng deleted the fix/wsl-path branch April 14, 2022 18:07
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.

2 participants