-
Notifications
You must be signed in to change notification settings - Fork 128
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 volume case issue in windows platform #199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @njuCZ !
The code looks pretty good, may I just ask for a test, to make sure that we don't reintroduce the same bug in the future as part of some refactoring?
A simple unit test testing pathEquals()
with different combinations of lowercase/uppercase should suffice.
And one nitpick - I'd try to avoid calling files or packages utils
generally, it makes it tempting to later add some more random unrelated logic and harder to find where things are. How about calling it path.go
?
16f7c6b
to
d776a7e
Compare
@radeksimko thanks for your suggestions, I have added the test case, please have a look again |
func pathEquals(path1, path2 string) bool { | ||
volume1 := filepath.VolumeName(path1) | ||
volume2 := filepath.VolumeName(path2) | ||
return strings.EqualFold(volume1, volume2) && path1[len(volume1):] == path2[len(volume2):] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about filesystems on Windows myself to decide, but I suspect we may need to compare of the other part of the path in case-insensitive way too at some point. It can be addressed as and when needed though.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
In windows platform, when initializing, the vscode sends root uri in this format
file:///c%3A/Users/user/workspace
, the volumnc
is in lowercase. The volume in all root module path are in lowercase.But when there is any change for
pluginlockfile
ormodulemanifestfile
, the file path starts with upper caseC
, which will cause path not match using==
, the language server could not get the latest schema or modules info.this is a similiar issue golang/go@935faf3. It seems windows path are case insentitive and linux is case sensitive
I think for now it's ok to only igore the volume case, there seems no need to ignore case for the whole path.