diff --git a/src/file.js b/src/file.js index 0525076..e4aa216 100644 --- a/src/file.js +++ b/src/file.js @@ -485,13 +485,18 @@ class File { this.detectResurrectionAfterDelay(); return; case 'rename': - this.setPath(eventPath); - this.subscribeToNativeChangeEvents(); - if (Grim.includeDeprecatedAPIs) { - this.emit('moved'); + if (eventPath !== this.path) { + this.setPath(eventPath); + this.subscribeToNativeChangeEvents(); + if (Grim.includeDeprecatedAPIs) { + this.emit('moved'); + } + this.emitter.emit('did-rename'); + return; } - this.emitter.emit('did-rename'); - return; + // Same file name - it's an atomic update + this.unsubscribeFromNativeChangeEvents(); + this.subscribeToNativeChangeEvents(); // because the inode changed case 'change': case 'resurrect': this.cachedContents = null;