kopia lustrzana https://github.com/c9/core
restore try block around settings read event
rodzic
66d2ac15f3
commit
3ac7d84a6d
|
@ -219,7 +219,10 @@ define(function(require, exports, module) {
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function read(json, isReset) {
|
function read(json, isReset, resetAll) {
|
||||||
|
if (testing || resetAll)
|
||||||
|
json = util.cloneObject(TEMPLATE);
|
||||||
|
|
||||||
KEYS.forEach(function(type) {
|
KEYS.forEach(function(type) {
|
||||||
if (json[type])
|
if (json[type])
|
||||||
model[type] = json[type];
|
model[type] = json[type];
|
||||||
|
@ -234,17 +237,24 @@ define(function(require, exports, module) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testing) {
|
var hadError = true;
|
||||||
KEYS.forEach(function(type) {
|
try {
|
||||||
model[type] = util.cloneObject(TEMPLATE[type]);
|
emit("read", {
|
||||||
|
model: model,
|
||||||
|
ext: plugin,
|
||||||
|
reset: isReset
|
||||||
});
|
});
|
||||||
|
hadError = false;
|
||||||
|
} finally {
|
||||||
|
// we do not want to catch the error to not hide it during development
|
||||||
|
if (hadError && !resetAll && !c9.debug && !testing) {
|
||||||
|
fs.writeFile(PATH.project + ".broken",
|
||||||
|
JSON.stringify(json, null, 4), function() {});
|
||||||
|
console.error("Error loading settings, reseting to defaults");
|
||||||
|
console.error("Old settings, are saved to " + PATH.project + ".broken");
|
||||||
|
return read(json, isReset, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit("read", {
|
|
||||||
model: model,
|
|
||||||
ext: plugin,
|
|
||||||
reset: isReset
|
|
||||||
});
|
|
||||||
|
|
||||||
if (inited)
|
if (inited)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,15 +59,6 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
}, plugin);
|
}, plugin);
|
||||||
|
|
||||||
settings.on("user/ace/@keyboardmode", function() {
|
|
||||||
var mode = settings.getJson("user/ace/@keyboardmode");
|
|
||||||
if (customKeymaps[mode]) {
|
|
||||||
settings.set("user/ace/@keyboardmode", "default");
|
|
||||||
settings.setJson("user/key-bindings", customKeymaps[mode]);
|
|
||||||
updateCommandsFromSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
settings.on("read", function(e) {
|
settings.on("read", function(e) {
|
||||||
updateCommandsFromSettings();
|
updateCommandsFromSettings();
|
||||||
}, plugin);
|
}, plugin);
|
||||||
|
@ -392,6 +383,10 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
var cmds = settings.getJson("user/key-bindings");
|
var cmds = settings.getJson("user/key-bindings");
|
||||||
if (cmds) {
|
if (cmds) {
|
||||||
|
if (!Array.isArray(cmds)) {
|
||||||
|
cmds = [];
|
||||||
|
settings.setJson("user/key-bindings", []);
|
||||||
|
}
|
||||||
cmds.forEach(function(cmd) {
|
cmds.forEach(function(cmd) {
|
||||||
if (!cmd || !cmd.command)
|
if (!cmd || !cmd.command)
|
||||||
return;
|
return;
|
||||||
|
|
Ładowanie…
Reference in New Issue