From 88e5dfa70f8f10d23f96961302ed5225969c0510 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Mon, 6 Jun 2016 10:29:35 -0400 Subject: [PATCH] Revert "VFS Fix collab code reverting for unsaved files" --- package.json | 2 +- plugins/c9.ide.watcher/gui.js | 42 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 4a611127..516f76e7 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "c9.ide.language.javascript.infer": "#b9c2e4bdb8", "c9.ide.language.jsonalyzer": "#72954f8da1", "c9.ide.language.codeintel": "#4e0a272229", - "c9.ide.collab": "#4885f8e5a3", + "c9.ide.collab": "#24e28024d7", "c9.ide.local": "#9169fec157", "c9.ide.find": "#a2dfc3e306", "c9.ide.find.infiles": "#488db22ee1", diff --git a/plugins/c9.ide.watcher/gui.js b/plugins/c9.ide.watcher/gui.js index 7e1979e8..e1330ca4 100644 --- a/plugins/c9.ide.watcher/gui.js +++ b/plugins/c9.ide.watcher/gui.js @@ -1,7 +1,7 @@ define(function(require, exports, module) { main.consumes = [ "Plugin", "fs", "settings", "preferences", "watcher", "tabManager", - "save", "dialog.question", "dialog.filechange", "threewaymerge", "collab" + "save", "dialog.question", "dialog.filechange", "threewaymerge" ]; main.provides = ["watcher.gui"]; return main; @@ -17,7 +17,6 @@ define(function(require, exports, module) { var question = imports["dialog.question"]; var filechange = imports["dialog.filechange"]; var threeWayMerge = imports.threewaymerge.merge; - var collab = imports.collab; var collabEnabled = options.collab; @@ -120,33 +119,33 @@ define(function(require, exports, module) { // Hook watcher events - // A change event sent from the watcher plugin + // Update a file watcher.on("change", function(e) { var tab = tabManager.findTab(e.path); if (tab) { - if (collabEnabled && tab.editorType == "ace") { - /* If the lastChange (added by collab) was greater than 1 second ago set up a watch - To ensure that collab makes this change, if not report an error. The lastChange - check is to avoid a race condition if collab updates before this function runs */ - if (!tab.meta.$lastCollabChange || tab.meta.$lastCollabChange < (Date.now() - 1000)) { - if (tab.meta.$collabChangeRegistered) { - clearTimeout(tab.meta.$collabChangeRegistered); - } - } - - return false; - } + // If collab picks this up and handles the change it will return false + if (emit("docChange", {tab: tab}) === false) + return; addChangedTab(tab, e.type === "change"); } }); - collab.on("change", function (e) { - var tab = tabManager.findTab(e.path); - if (tab) { - addChangedTab(tab, e.type === "change"); - } - }); + // Directory watcher is not needed if the normal watcher works + // watcher.on("directory", function(e) { + // var base = e.path; + // var files = e.files; + // + // // Rename all tabs + // tabManager.getTabs().forEach(function(tab) { + // if (tab.path && tab.path.indexOf(base) == 0) { + // // If the file is gone, lets notify the user + // if (files.indexOf(tab.path) == -1) { + // resolveFileDelete(tab); + // } + // } + // }); + // }); watcher.on("delete", function(e) { var tab = tabManager.findTab(e.path); @@ -294,6 +293,7 @@ define(function(require, exports, module) { function automerge(tab, data) { if (!settings.getBool("user/general/@automerge")) return false; + return merge(tab, data); }