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:
commit
531d58fbea
1 changed files with 4 additions and 5 deletions
|
@ -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", "");
|
||||||
|
|
Loading…
Reference in a new issue