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;
|
||||
}
|
||||
|
||||
function read(json, isReset) {
|
||||
function read(json, isReset, resetAll) {
|
||||
if (testing || resetAll)
|
||||
json = util.cloneObject(TEMPLATE);
|
||||
|
||||
KEYS.forEach(function(type) {
|
||||
if (json[type])
|
||||
model[type] = json[type];
|
||||
|
@ -234,17 +237,24 @@ define(function(require, exports, module) {
|
|||
});
|
||||
}
|
||||
|
||||
if (testing) {
|
||||
KEYS.forEach(function(type) {
|
||||
model[type] = util.cloneObject(TEMPLATE[type]);
|
||||
var hadError = true;
|
||||
try {
|
||||
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)
|
||||
return;
|
||||
|
|
|
@ -59,15 +59,6 @@ define(function(require, exports, module) {
|
|||
}
|
||||
}, 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) {
|
||||
updateCommandsFromSettings();
|
||||
}, plugin);
|
||||
|
@ -392,6 +383,10 @@ define(function(require, exports, module) {
|
|||
|
||||
var cmds = settings.getJson("user/key-bindings");
|
||||
if (cmds) {
|
||||
if (!Array.isArray(cmds)) {
|
||||
cmds = [];
|
||||
settings.setJson("user/key-bindings", []);
|
||||
}
|
||||
cmds.forEach(function(cmd) {
|
||||
if (!cmd || !cmd.command)
|
||||
return;
|
||||
|
|
Ładowanie…
Reference in New Issue