From 38d8d710912a3fa266dd7dc02da5ec405fa0c820 Mon Sep 17 00:00:00 2001 From: Dara Hak Date: Wed, 28 Dec 2016 22:43:57 +0100 Subject: [PATCH] Also pause the watcher on deletions to avoid triggering more than one warning dialog. --- app/renderer/abr-document.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/renderer/abr-document.js b/app/renderer/abr-document.js index ca38b9a..1fe838d 100644 --- a/app/renderer/abr-document.js +++ b/app/renderer/abr-document.js @@ -390,6 +390,8 @@ AbrDocument.prototype = { that.startWatcher(); }); } else { + // The previous document is dropped from the editor. + // The watcher will resume on save. that.setDirty(); that.updateWindowTitle(); } @@ -399,8 +401,8 @@ AbrDocument.prototype = { if (keepFile) { that.setDirty(); that.updateWindowTitle(); + that.startWatcher(); } else { - that.pauseWatcher(); that.clear(); } }); @@ -408,10 +410,13 @@ AbrDocument.prototype = { }; this.watcher = files.createWatcher(this.path, { change: function (path) { + // Pause the watcher to avoid triggering multiple warning dialogs + // while the first one is being handled. that.pauseWatcher(); runOnFocus(handleAsyncFileChange, path); }, unlink: function (path) { + that.pauseWatcher(); runOnFocus(handleAsyncFileChange, path); }, error: function (err) {