-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Conversation
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
👍 |
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.