Skip to content

Commit 4046bb1

Browse files
committed
Do not send first missing file event as well.
1 parent 0c6ef34 commit 4046bb1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/compiler/sys.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,16 +752,17 @@ namespace ts {
752752
};
753753

754754
function fileChanged(curr: any, prev: any) {
755+
// previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears)
756+
// In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation
757+
const isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
755758
if (+curr.mtime === 0) {
756-
if (eventKind === FileWatcherEventKind.Deleted) {
759+
if (isPreviouslyDeleted) {
757760
// Already deleted file, no need to callback again
758761
return;
759762
}
760763
eventKind = FileWatcherEventKind.Deleted;
761764
}
762-
// previous event kind check is to ensure we send created event when file is restored or renamed twice (that is it disappears and reappears)
763-
// since in that case the prevTime returned is same as prev time of event when file was deleted as per node documentation
764-
else if (+prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted) {
765+
else if (isPreviouslyDeleted) {
765766
eventKind = FileWatcherEventKind.Created;
766767
}
767768
// If there is no change in modified time, ignore the event

0 commit comments

Comments
 (0)