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

internal/filesystem: Account for case-insensitive filesystems #796

Open
radeksimko opened this issue Feb 21, 2022 · 0 comments
Open

internal/filesystem: Account for case-insensitive filesystems #796

radeksimko opened this issue Feb 21, 2022 · 0 comments
Labels
bug Something isn't working text-synchronization https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocum

Comments

@radeksimko
Copy link
Member

radeksimko commented Feb 21, 2022

This was discovered during #771 but the problem existed prior to that PR and the PR isn't addressing it in any way.

func (fsys *fsystem) ReadDir(name string) ([]fs.DirEntry, error) {
memList, err := afero.NewIOFS(fsys.memFs).ReadDir(name)
if err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("memory FS: %w", err)
}
osList, err := afero.NewIOFS(fsys.osFs).ReadDir(name)
if err != nil && !os.IsNotExist(err) {
return nil, fmt.Errorf("OS FS: %w", err)
}
list := memList
for _, osEntry := range osList {
if fileIsInList(list, osEntry) {
continue
}
list = append(list, osEntry)
}
return list, nil
}
func fileIsInList(list []fs.DirEntry, entry fs.DirEntry) bool {
for _, di := range list {
if di.Name() == entry.Name() {
return true
}
}
return false
}

Background

Case-insensitive filesystems are relatively common (default) on Windows. They are however also commonly case-preserving. And given that it's (often? #75 ) the same OS running the client and the server, it is unlikely that we'd end up with two files which only differ in casing. That is likely why this never came up before.

Proposal

  1. Understand if there are cases where OS of client can differ from OS of server, or the underlying filesystem (maybe in case of shared volumes?)
  2. Check what other language servers do and try to understand why - i.e. what are the edge cases where the casing in file names can differ
  3. Implement case-insensitive solution, if necessary - or document why we don't need to

Related: spf13/afero#126

@radeksimko radeksimko added bug Something isn't working text-synchronization https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocum labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working text-synchronization https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocum
Projects
None yet
Development

No branches or pull requests

1 participant