Skip to content

Commit 6ed94b1

Browse files
authored
Merge pull request microsoft#17083 from amcasey/Vsts461481
Correct FileWatcherEventKind in server polling method
2 parents f45ccf5 + 911f1f8 commit 6ed94b1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/server/server.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,18 @@ namespace ts.server {
526526
if (err) {
527527
watchedFile.callback(watchedFile.fileName, FileWatcherEventKind.Changed);
528528
}
529-
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
530-
watchedFile.mtime = stats.mtime;
531-
const eventKind = watchedFile.mtime.getTime() === 0
532-
? FileWatcherEventKind.Deleted
533-
: FileWatcherEventKind.Changed;
534-
watchedFile.callback(watchedFile.fileName, eventKind);
529+
else {
530+
const oldTime = watchedFile.mtime.getTime();
531+
const newTime = stats.mtime.getTime();
532+
if (oldTime !== newTime) {
533+
watchedFile.mtime = stats.mtime;
534+
const eventKind = oldTime === 0
535+
? FileWatcherEventKind.Created
536+
: newTime === 0
537+
? FileWatcherEventKind.Deleted
538+
: FileWatcherEventKind.Changed;
539+
watchedFile.callback(watchedFile.fileName, eventKind);
540+
}
535541
}
536542
});
537543
}

0 commit comments

Comments
 (0)