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 casing from canonical uri #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/helper/paths.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import { URI } from 'vscode-uri';
import { upath } from '../core';
import { pathRelativeToWorkspace, getWorkspaceFolders } from '../host';

// from https://github.com/microsoft/vscode-eslint/blob/d97a8b5e99ad30d2ce32ffa5646447202f873413/server/src/eslintServer.ts#L816
function getFileSystemPath(uri: URI): string {
let result = uri.fsPath;
if (process.platform === 'win32' && result.length >= 2 && result[1] === ':') {
// Node by default uses an upper case drive letter and ESLint uses
// === to compare paths which results in the equal check failing
// if the drive letter is lower case in th URI. Ensure upper case.
result = result[0].toUpperCase() + result.substr(1);
}
if (process.platform === 'win32' || process.platform === 'darwin') {
const realpath = fs.realpathSync.native(result);
// Only use the real path if only the casing has changed.
if (realpath.toLowerCase() === result.toLowerCase()) {
result = realpath;
}
}
return result;
}

export function simplifyPath(absolutePath: string) {
return pathRelativeToWorkspace(absolutePath);
}

// FIXME: use fs.pathResolver instead of upath
export function toRemotePath(localPath: string, localContext: string, remoteContext: string) {
return upath.join(remoteContext, path.relative(localContext, localPath));
return upath.join(remoteContext, path.relative(getFileSystemPath(localContext), getFileSystemPath(localPath)));
}

// FIXME: use fs.pathResolver instead of upath
Expand Down