kopia lustrzana https://github.com/c9/core
Refactoring Gui
rodzic
82b9510125
commit
75a5cc1277
|
@ -82,31 +82,23 @@ define(function(require, exports, module) {
|
||||||
}, plugin);
|
}, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabManager.getTabs().forEach(function(tab) {
|
function initializeTab(tab) {
|
||||||
if (!tab.path)
|
if (!tab.path) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (tab.document.undoManager.isAtBookmark()) {
|
if (tab.document.undoManager.isAtBookmark()) {
|
||||||
initializeDocument(tab.document);
|
initializeDocument(tab.document);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
console.error("Unsupported state");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tab.classList.contains("conflict")) {
|
if (tab.classList.contains("conflict")) {
|
||||||
addChangedTab(tab, comparisonType.TIMESTAMP_AND_CONTENTS);
|
addChangedTab(tab, comparisonType.TIMESTAMP_AND_CONTENTS);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
tabManager.getTabs().forEach(initializeTab);
|
||||||
tabManager.on("open", function(e) {
|
tabManager.on("open", function(e) {
|
||||||
initializeDocument(e.tab.document);
|
initializeTab(e.tab);
|
||||||
if (e.tab.classList.contains("conflict")) {
|
|
||||||
addChangedTab(e.tab, comparisonType.TIMESTAMP_AND_CONTENTS);
|
|
||||||
}
|
|
||||||
}, plugin);
|
}, plugin);
|
||||||
|
|
||||||
// Hook the save of the document value
|
// Hook the save of the document value
|
||||||
|
|
||||||
save.on("beforeSave", function(e) {
|
save.on("beforeSave", function(e) {
|
||||||
e.document.meta.$savingValue = e.save;
|
e.document.meta.$savingValue = e.save;
|
||||||
if (e.tab.classList.contains("conflict")) {
|
if (e.tab.classList.contains("conflict")) {
|
||||||
|
@ -178,6 +170,10 @@ define(function(require, exports, module) {
|
||||||
delete changedPaths[path];
|
delete changedPaths[path];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isTabSaving(tab) {
|
||||||
|
return tab.document.meta.$saving;
|
||||||
|
}
|
||||||
|
|
||||||
function addChangedTab(tab, doubleCheckComparisonType) {
|
function addChangedTab(tab, doubleCheckComparisonType) {
|
||||||
// If we already have a dialog open, just update it, but mark the value dirty
|
// If we already have a dialog open, just update it, but mark the value dirty
|
||||||
if (changedPaths[tab.path]) {
|
if (changedPaths[tab.path]) {
|
||||||
|
@ -188,8 +184,14 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore changes that come in while tab is being saved
|
// Ignore changes that come in while tab is being saved
|
||||||
if (tab.document.meta.$saving) {
|
if (isTabSaving(tab)) return;
|
||||||
console.log("[watchers] Watcher fired, but tab is still saving", path);
|
|
||||||
|
// If the terminal is currently focussed, lets wait until
|
||||||
|
// another tab is focussed
|
||||||
|
if (tabManager.focussedTab && tabManager.focussedTab.editorType == "terminal") {
|
||||||
|
tabManager.once("focus", function(){
|
||||||
|
addChangedTab(tab, comparisonType.CONTENTS);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,16 +200,6 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
changedPaths[tab.path] = { tab: tab, resolve: resolve };
|
changedPaths[tab.path] = { tab: tab, resolve: resolve };
|
||||||
|
|
||||||
// If the terminal is currently focussed, lets wait until
|
|
||||||
// another tab is focussed
|
|
||||||
if (tabManager.focussedTab
|
|
||||||
&& tabManager.focussedTab.editorType == "terminal") {
|
|
||||||
tabManager.once("focus", function(){
|
|
||||||
addChangedTab(tab, comparisonType.CONTENTS);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolve() {
|
function resolve() {
|
||||||
if (collabEnabled && collab.send)
|
if (collabEnabled && collab.send)
|
||||||
collab.send({type: "RESOLVE_CONFLICT", data: {docId: path}});
|
collab.send({type: "RESOLVE_CONFLICT", data: {docId: path}});
|
||||||
|
|
Ładowanie…
Reference in New Issue