[Code] fix another path problem on windows (#38072) (#38215)

This commit is contained in:
Yulong 2019-06-06 12:16:35 +08:00 committed by GitHub
parent ff466b5d02
commit 80038e3c8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -267,7 +267,8 @@ export class WorkspaceHandler {
if (uri && uri.startsWith(prefix)) {
const locationPath = fs.realpathSync(decodeURIComponent(uri.substring(prefix.length)));
const workspacePath = fs.realpathSync(decodeURIComponent(this.workspacePath));
if (locationPath.startsWith(workspacePath)) {
// On windows, it's possible one path has c:\ and another has C:\, so we need compare case-insensitive
if (locationPath.toLocaleLowerCase().startsWith(workspacePath.toLocaleLowerCase())) {
let relativePath = path.relative(workspacePath, locationPath);
if (path.sep === '\\') {
relativePath = relativePath.replace(/\\/gi, '/');