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 volume case issue in windows platform #199

Merged
merged 3 commits into from
Jul 2, 2020

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented Jul 2, 2020

In windows platform, when initializing, the vscode sends root uri in this format file:///c%3A/Users/user/workspace, the volumn c is in lowercase. The volume in all root module path are in lowercase.

But when there is any change for pluginlockfile or modulemanifestfile, the file path starts with upper case C, 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.

Copy link
Member

@radeksimko radeksimko left a 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?

@radeksimko radeksimko added the bug Something isn't working label Jul 2, 2020
@njuCZ
Copy link
Contributor Author

njuCZ commented Jul 2, 2020

@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):]
Copy link
Member

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.

@ghost
Copy link

ghost commented Aug 1, 2020

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Aug 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants