microsoft/python-language-server

PathUtils NormalizePath method

makzimus opened this issue · 2 comments

I hesitate to file this as a bug because it may not be but the code in NormalizePath is doing this:

                if (parts[i] == "..") {
                    var found = false;
                    for (var j = i - 1; j >= 0; --j) {
                        if (!string.IsNullOrEmpty(parts[j])) {
                            parts[i] = null;
                            parts[j] = null;
                            found = true;
                            break;
                        }
                    }
                    if (!found && !string.IsNullOrEmpty(root)) {
                        parts[i] = null;
                    }
                    continue;
                }

This is transforming the user search paths that are relative more than one level up.
Ex: "../../libs" will transform to "libs".

Is this intended and relative paths just aren't supported? Or is this just old code that needs updating?

The subsequent line will also break relative path parts.

parts[i] = parts[i].TrimEnd(' ', '.');

Maybe related to this #1975 ?