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

ignore casing when converting a source file path to relative path #9213

Merged
merged 2 commits into from
Jun 20, 2016

Conversation

zhengbli
Copy link
Contributor

Fixes #8837

When converting an absolute file name to a relative file name, sometimes the commonSourceDirectory and the absolute file name have different casing, which should be ignored.

@@ -2330,7 +2330,9 @@ namespace ts {

export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) {
let sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory());
sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), "");
const commonSourceDirectory = host.getCommonSourceDirectory();
const isSourceFileInCommonSourceDirectory = sourceFilePath.toLowerCase().indexOf(commonSourceDirectory.toLowerCase()) === 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be done without checking ignoreCase option in compilerOptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only found a forceConsistentCasingInFileNames option in the compilerOptions. Is that what you are referring to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant usage of getCanonicalFileName instead to handle the casing option just like the way we do in relative name computation or common directory name compuation.

Copy link
Contributor Author

@zhengbli zhengbli Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case sensitivity used by getCanonicalFileName is actually not very trustable, because we tell the file system case sensitivity solely by OS. However, in some cases this is wrong, for example network mounted file system on Windows, or HFS / HFS+ on OSX. Relying on it has caused many troubles previously when dealing with file watching. So I think it might be better if we only use the canonical file name internally for comparison purpose, but not when directly talking to the file system.

@zhengbli
Copy link
Contributor Author

@mhegazy @vladima can you take a look?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 20, 2016

👍

@zhengbli zhengbli merged commit 7b3abc6 into microsoft:master Jun 20, 2016
@zhengbli zhengbli deleted the fixRealPath branch June 20, 2016 21:07
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants