From bc4f1f4006f83a4aabe5b12f00bcddb6b241a2c2 Mon Sep 17 00:00:00 2001 From: Arzhan Kinzhalin Date: Tue, 25 Feb 2014 18:07:51 -0300 Subject: [PATCH] Address review comments. --- src/nls/root/strings.js | 5 ++--- src/preferences/PreferencesBase.js | 20 +++++--------------- src/preferences/PreferencesManager.js | 6 +++--- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index fe9383dd390..49b79bc4156 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -66,9 +66,8 @@ define({ "ERROR_CREATING_FILE" : "An error occurred when trying to create the {0} {1}. {2}", // Application preferences corrupt error strings - "ERROR_PREFS_CORRUPT_TITLE" : "Preferences file is corrupt", - "ERROR_PREFS_CORRUPT" : "{APP_NAME} preferences file is not a valid JSON and cannot be parsed. It will now be opened so that you could fix it. You will need to restart or reload {APP_NAME} for the changes to take effect.", - + "ERROR_PREFS_CORRUPT_TITLE" : "Error reading preferences", + "ERROR_PREFS_CORRUPT" : "Your preferences file is not valid JSON. The file will be opened so that you can correct the format. You will need to restart {APP_NAME} for the changes to take effect.", // Application error strings "ERROR_IN_BROWSER_TITLE" : "Oops! {APP_NAME} doesn't run in browsers yet.", diff --git a/src/preferences/PreferencesBase.js b/src/preferences/PreferencesBase.js index f0d002b9d46..d1061cbfc3a 100644 --- a/src/preferences/PreferencesBase.js +++ b/src/preferences/PreferencesBase.js @@ -1034,11 +1034,11 @@ define(function (require, exports, module) { scopeOrder: ["default"], _shadowScopeOrder: [{ id: "default", + scope: this._scopes["default"], promise: (new $.Deferred()).resolve().promise() }] }; - this._pendingEvents = {}; this._pendingScopes = {}; this._saveInProgress = false; @@ -1257,7 +1257,6 @@ define(function (require, exports, module) { .fail(function (err) { // clean up all what's been done up to this point _.pull(shadowScopeOrder, shadowEntry); - delete this._pendingEvents[id]; }.bind(this)); if (this._pendingScopes[id]) { var pending = this._pendingScopes[id]; @@ -1298,6 +1297,7 @@ define(function (require, exports, module) { if (scope) { _.pull(this._defaultContext.scopeOrder, id); var $this = $(this); + $(scope).off(".prefsys"); $this.trigger(SCOPEORDER_CHANGE, { id: id, action: "removed" @@ -1305,7 +1305,6 @@ define(function (require, exports, module) { $this.trigger(PREFERENCE_CHANGE, { ids: scope.getKeys() }); - $(scope).off(".prefsys"); } }, @@ -1377,22 +1376,13 @@ define(function (require, exports, module) { if (!scope) { return; } - delete this._scopes[id]; - delete this._pendingEvents[id]; - _.pull(this._defaultContext.scopeOrder, id); + + this.removeFromScopeOrder(id); shadowIndex = _.findIndex(this._defaultContext._shadowScopeOrder, function (entry) { return entry.id === id; }); this._defaultContext._shadowScopeOrder.splice(shadowIndex, 1); - $(this).trigger(SCOPEORDER_CHANGE, { - id: id, - action: "removed" - }); - $(this).trigger(PREFERENCE_CHANGE, { - ids: scope.getKeys() - }); - - $(scope).off(PREFERENCE_CHANGE); + delete this._scopes[id]; }, /** diff --git a/src/preferences/PreferencesManager.js b/src/preferences/PreferencesManager.js index faf308cf63b..1c8a07f99aa 100644 --- a/src/preferences/PreferencesManager.js +++ b/src/preferences/PreferencesManager.js @@ -246,7 +246,7 @@ define(function (require, exports, module) { * @private * @type {$.Deferred} */ - var _deferred = new $.Deferred(); + var _prefManagerReadyDeferred = new $.Deferred(); /** * Promises to add scopes. Used at init time only. @@ -292,7 +292,7 @@ define(function (require, exports, module) { Async.waitForAll(_addScopePromises) .always(function () { - _deferred.resolve(); + _prefManagerReadyDeferred.resolve(); }); }); @@ -639,7 +639,6 @@ define(function (require, exports, module) { } // Private API for unit testing and use elsewhere in Brackets core - exports.ready = _deferred.promise(); exports._isUserScopeCorrupt = function () { return _userScopeCorrupt; }; exports._manager = preferencesManager; exports._setCurrentEditingFile = _setCurrentEditingFile; @@ -651,6 +650,7 @@ define(function (require, exports, module) { exports.CURRENT_FILE = CURRENT_FILE; exports.CURRENT_PROJECT = CURRENT_PROJECT; + exports.ready = _prefManagerReadyDeferred.promise(); exports.getUserPrefFile = getUserPrefFile; exports.get = get; exports.set = set;