Merge pull request #27563 from Microsoft/nonPollingWatcher

Ignore the directory watchers invoked in non polling watch mode with no relative file name information
This commit is contained in:
Sheetal Nandi 2018-10-09 13:22:34 -07:00 committed by GitHub
commit 531d58fbea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -796,11 +796,10 @@ namespace ts {
dirName, dirName,
(_eventName: string, relativeFileName) => { (_eventName: string, relativeFileName) => {
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
const fileName = !isString(relativeFileName) if (!isString(relativeFileName)) { return; }
? undefined! // TODO: GH#18217 const fileName = getNormalizedAbsolutePath(relativeFileName, dirName);
: getNormalizedAbsolutePath(relativeFileName, dirName);
// Some applications save a working file via rename operations // Some applications save a working file via rename operations
const callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName)); const callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
if (callbacks) { if (callbacks) {
for (const fileCallback of callbacks) { for (const fileCallback of callbacks) {
fileCallback(fileName, FileWatcherEventKind.Changed); fileCallback(fileName, FileWatcherEventKind.Changed);
@ -847,7 +846,7 @@ namespace ts {
} }
} }
type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string) => void; type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string | undefined) => void;
function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback { function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback {
return (_fileName, eventKind) => callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); return (_fileName, eventKind) => callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "");