Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-6660
Browse files Browse the repository at this point in the history
Conflicts:
	src/preferences/PreferencesManager.js
  • Loading branch information
busykai committed Feb 25, 2014
2 parents 690fb9c + c7d08d7 commit 870a9ef
Show file tree
Hide file tree
Showing 73 changed files with 1,321 additions and 953 deletions.
5 changes: 5 additions & 0 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,10 @@ define(function LiveDevelopment(require, exports, module) {
return _server;
}

function getServerBaseUrl() {
return _server && _server.getBaseUrl();
}

// For unit testing
exports.launcherUrl = launcherUrl;
exports._getServer = _getServer;
Expand All @@ -1365,4 +1369,5 @@ define(function LiveDevelopment(require, exports, module) {
exports.redrawHighlight = redrawHighlight;
exports.init = init;
exports.getCurrentProjectServerConfig = getCurrentProjectServerConfig;
exports.getServerBaseUrl = getServerBaseUrl;
});
20 changes: 14 additions & 6 deletions src/LiveDevelopment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ define(function main(require, exports, module) {
ExtensionUtils = require("utils/ExtensionUtils"),
StringUtils = require("utils/StringUtils");

var prefs;
var params = new UrlParams();
var config = {
experimental: false, // enable experimental features
Expand Down Expand Up @@ -125,8 +124,8 @@ define(function main(require, exports, module) {
if (LiveDevelopment.status >= LiveDevelopment.STATUS_CONNECTING) {
LiveDevelopment.close();
} else {
if (!params.get("skipLiveDevelopmentInfo") && !prefs.getValue("afterFirstLaunch")) {
prefs.setValue("afterFirstLaunch", "true");
if (!params.get("skipLiveDevelopmentInfo") && !PreferencesManager.getViewState("livedev.afterFirstLaunch")) {
PreferencesManager.setViewState("livedev.afterFirstLaunch", "true");
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_INFO,
Strings.LIVE_DEVELOPMENT_INFO_TITLE,
Expand Down Expand Up @@ -213,7 +212,7 @@ define(function main(require, exports, module) {
} else {
LiveDevelopment.hideHighlight();
}
prefs.setValue("highlight", config.highlight);
PreferencesManager.setViewState("livedev.highlight", config.highlight);
}

/** Setup window references to useful LiveDevelopment modules */
Expand Down Expand Up @@ -256,9 +255,18 @@ define(function main(require, exports, module) {
});

// init prefs
prefs = PreferencesManager.getPreferenceStorage(module, {highlight: true});
PreferencesManager.stateManager.definePreference("livedev.highlight", "boolean", true)
.on("change", function () {
config.highlight = PreferencesManager.getViewState("livedev.highlight");
_updateHighlightCheckmark();
});

PreferencesManager.convertPreferences(module, {
"highlight": "user livedev.highlight",
"afterFirstLaunch": "user livedev.afterFirstLaunch"
}, true);

config.highlight = prefs.getValue("highlight");
config.highlight = PreferencesManager.getViewState("livedev.highlight");

// init commands
CommandManager.register(Strings.CMD_LIVE_FILE_PREVIEW, Commands.FILE_LIVE_FILE_PREVIEW, _handleGoLiveCommand);
Expand Down
30 changes: 15 additions & 15 deletions src/brackets.config.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"config" :
{
"app_title" : "Brackets",
"app_name_about" : "Brackets",
"about_icon" : "styles/images/brackets_icon.svg",
"update_info_url" : "http://dev.brackets.io/updates/stable/",
"how_to_use_url" : "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
"forum_url" : "https://groups.google.com/forum/?fromgroups#!forum/brackets-dev",
"release_notes_url" : "https://github.com/adobe/brackets/wiki/Release-Notes",
"report_issue_url" : "https://github.com/adobe/brackets/wiki/How-to-Report-an-Issue",
"twitter_url" : "https://twitter.com/brackets",
"troubleshoot_url" : "https://github.com/adobe/brackets/wiki/Troubleshooting#wiki-livedev",
"twitter_name" : "@brackets",
"contributors_url" : "https://api.github.com/repos/adobe/brackets/contributors",
"extension_wiki_url": "https://github.com/adobe/brackets/wiki/Brackets-Extensions",
"extension_registry": "https://s3.amazonaws.com/extend.brackets/registry.json",
"extension_url" : "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
"app_title" : "Brackets",
"app_name_about" : "Brackets",
"about_icon" : "styles/images/brackets_icon.svg",
"update_info_url" : "http://dev.brackets.io/updates/stable/",
"how_to_use_url" : "https://github.com/adobe/brackets/wiki/How-to-Use-Brackets",
"forum_url" : "https://groups.google.com/forum/?fromgroups#!forum/brackets-dev",
"release_notes_url" : "https://github.com/adobe/brackets/wiki/Release-Notes",
"report_issue_url" : "https://github.com/adobe/brackets/wiki/How-to-Report-an-Issue",
"twitter_url" : "https://twitter.com/brackets",
"troubleshoot_url" : "https://github.com/adobe/brackets/wiki/Troubleshooting#wiki-livedev",
"twitter_name" : "@brackets",
"contributors_url" : "https://api.github.com/repos/adobe/brackets/contributors",
"extension_listing_url" : "",
"extension_registry" : "https://s3.amazonaws.com/extend.brackets/registry.json",
"extension_url" : "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
"linting.enabled_by_default" : true
}
}
7 changes: 3 additions & 4 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,10 @@ define(function (require, exports, module) {
// the samples folder on first launch), open it automatically. (We explicitly check for the
// samples folder in case this is the first time we're launching Brackets after upgrading from
// an old version that might not have set the "afterFirstLaunch" pref.)
var prefs = PreferencesManager.getPreferenceStorage(module),
deferred = new $.Deferred();
var deferred = new $.Deferred();

if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) {
prefs.setValue("afterFirstLaunch", "true");
if (!params.get("skipSampleProjectLoad") && !PreferencesManager.getViewState("afterFirstLaunch")) {
PreferencesManager.setViewState("afterFirstLaunch", "true");
if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) {
FileSystem.resolve(initialProjectPath + "index.html", function (err, file) {
if (!err) {
Expand Down
2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"troubleshoot_url": "https://github.com/adobe/brackets/wiki/Troubleshooting#wiki-livedev",
"twitter_name": "@brackets",
"contributors_url": "https://api.github.com/repos/adobe/brackets/contributors",
"extension_wiki_url": "https://github.com/adobe/brackets/wiki/Brackets-Extensions",
"extension_listing_url": "",
"extension_registry": "https://s3.amazonaws.com/extend.brackets/registry.json",
"extension_url": "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
"linting.enabled_by_default": true
Expand Down
54 changes: 37 additions & 17 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ define(function (require, exports, module) {
*/
var _currentDocument = null;

/**
* @private
* @type {PreferenceStorage}
*/
var _prefs = {};

/**
* Returns the Document that is currently open in the editor UI. May be null.
* When this changes, DocumentManager dispatches a "currentDocumentChange" event. The current
Expand Down Expand Up @@ -816,11 +810,13 @@ define(function (require, exports, module) {
*/
function _savePreferences() {
// save the working set file paths
var files = [],
isActive = false,
workingSet = getWorkingSet(),
currentDoc = getCurrentDocument(),
projectRoot = ProjectManager.getProjectRoot();
var files = [],
isActive = false,
workingSet = getWorkingSet(),
currentDoc = getCurrentDocument(),
projectRoot = ProjectManager.getProjectRoot(),
context = { location : { scope: "user",
layer: "project" } };

if (!projectRoot) {
return;
Expand All @@ -843,8 +839,8 @@ define(function (require, exports, module) {
}
});

// append file root to make file list unique for each project
_prefs.setValue("files_" + projectRoot.fullPath, files);
// Writing out working set files using the project layer specified in 'context'.
PreferencesManager.setViewState("project.files", files, context);
}

/**
Expand All @@ -854,7 +850,11 @@ define(function (require, exports, module) {
function _projectOpen(e) {
// file root is appended for each project
var projectRoot = ProjectManager.getProjectRoot(),
files = _prefs.getValue("files_" + projectRoot.fullPath);
files = [],
context = { location : { scope: "user",
layer: "project" } };

files = PreferencesManager.getViewState("project.files", context);

console.assert(Object.keys(_openDocuments).length === 0); // no files leftover from prev proj

Expand Down Expand Up @@ -992,6 +992,29 @@ define(function (require, exports, module) {
$(exports).triggerHandler("documentSaved", doc);
});

/**
* @private
* Examine each preference key for migration of the working set files.
* If the key has a prefix of "files_/", then it is a working set files
* preference from old preference model.
*
* @param {string} key The key of the preference to be examined
* for migration of working set files.
* @return {?string} - the scope to which the preference is to be migrated
*/
function _checkPreferencePrefix(key) {
var pathPrefix = "files_";
if (key.indexOf(pathPrefix) === 0) {
// Get the project path from the old preference key by stripping "files_".
var projectPath = key.substr(pathPrefix.length);
return "user project.files " + projectPath;
}

return null;
}

PreferencesManager.convertPreferences(module, {"files_": "user"}, true, _checkPreferencePrefix);

// Handle file saves that may affect preferences
$(exports).on("documentSaved", function (e, doc) {
PreferencesManager.fileChanged(doc.file.fullPath);
Expand Down Expand Up @@ -1028,9 +1051,6 @@ define(function (require, exports, module) {
exports.notifyPathNameChanged = notifyPathNameChanged;
exports.notifyPathDeleted = notifyPathDeleted;

// Setup preferences
_prefs = PreferencesManager.getPreferenceStorage(module);

// Performance measurements
PerfUtils.createPerfMeasurement("DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH", "DocumentManager.getDocumentForPath()");

Expand Down
4 changes: 2 additions & 2 deletions src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ define(function (require, exports, module) {
};
} else {
_addHint = function (hint) {
view.hints.push({ formattedHint: (hint instanceof $) ? "" : hint });
view.hints.push({ formattedHint: (hint.jquery) ? "" : hint });
};
}

Expand Down Expand Up @@ -237,7 +237,7 @@ define(function (require, exports, module) {
$element.data("hint", hint);

// insert jQuery hint objects after the template is rendered
if (hint instanceof $) {
if (hint.jquery) {
$element.find(".codehint-item").append(hint);
}
});
Expand Down
29 changes: 16 additions & 13 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,40 @@ define(function (require, exports, module) {
_ = require("thirdparty/lodash");

/** Editor preferences */
var USE_TAB_CHAR = "useTabChar",
var SMART_INDENT = "smartIndent",
USE_TAB_CHAR = "useTabChar",
TAB_SIZE = "tabSize",
SPACE_UNITS = "spaceUnits",
CLOSE_BRACKETS = "closeBrackets",
SHOW_LINE_NUMBERS = "showLineNumbers",
STYLE_ACTIVE_LINE = "styleActiveLine",
WORD_WRAP = "wordWrap",
CLOSE_TAGS = "closeTags",
cmOptions = {};

// Mappings from Brackets preferences to CodeMirror options
cmOptions[SMART_INDENT] = "smartIndent";
cmOptions[USE_TAB_CHAR] = "indentWithTabs";
cmOptions[TAB_SIZE] = "indentUnit";
cmOptions[SPACE_UNITS] = "indentUnit";
cmOptions[CLOSE_BRACKETS] = "autoCloseBrackets";
cmOptions[SHOW_LINE_NUMBERS] = "lineNumbers";
cmOptions[STYLE_ACTIVE_LINE] = "styleActiveLine";
cmOptions[WORD_WRAP] = "lineWrapping";
cmOptions[CLOSE_TAGS] = "autoCloseTags";

PreferencesManager.definePreference(SMART_INDENT, "boolean", true);
PreferencesManager.definePreference(USE_TAB_CHAR, "boolean", false);
PreferencesManager.definePreference(TAB_SIZE, "number", 4);
PreferencesManager.definePreference(SPACE_UNITS, "number", 4);
PreferencesManager.definePreference(CLOSE_BRACKETS, "boolean", false);
PreferencesManager.definePreference(SHOW_LINE_NUMBERS, "boolean", true);
PreferencesManager.definePreference(STYLE_ACTIVE_LINE, "boolean", false);
PreferencesManager.definePreference(WORD_WRAP, "boolean", true);
PreferencesManager.definePreference(CLOSE_TAGS, "Object", { whenOpening: true, whenClosing: true, indentTags: [] });

var editorOptions = [USE_TAB_CHAR, TAB_SIZE, SPACE_UNITS, CLOSE_BRACKETS,
SHOW_LINE_NUMBERS, STYLE_ACTIVE_LINE, WORD_WRAP];
var editorOptions = [SMART_INDENT, USE_TAB_CHAR, TAB_SIZE, SPACE_UNITS, CLOSE_BRACKETS,
SHOW_LINE_NUMBERS, STYLE_ACTIVE_LINE, WORD_WRAP, CLOSE_TAGS];

/** Editor preferences */

Expand Down Expand Up @@ -381,6 +387,7 @@ define(function (require, exports, module) {
// (note: CodeMirror doesn't actually require using 'new', but jslint complains without it)
this._codeMirror = new CodeMirror(container, {
electricChars: false, // we use our own impl of this to avoid CodeMirror bugs; see _checkElectricChars()
smartIndent: currentOptions[SMART_INDENT],
indentWithTabs: currentOptions[USE_TAB_CHAR],
tabSize: currentOptions[TAB_SIZE],
indentUnit: currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS],
Expand All @@ -393,11 +400,7 @@ define(function (require, exports, module) {
dragDrop: false,
extraKeys: codeMirrorKeyMap,
autoCloseBrackets: currentOptions[CLOSE_BRACKETS],
autoCloseTags: {
whenOpening: true,
whenClosing: true,
indentTags: []
},
autoCloseTags: currentOptions[CLOSE_TAGS],
cursorScrollMargin: 3
});

Expand Down Expand Up @@ -1599,7 +1602,7 @@ define(function (require, exports, module) {
* @param {boolean} value
*/
Editor.setUseTabChar = function (value) {
PreferencesManager.setValueAndSave(USE_TAB_CHAR, value);
PreferencesManager.set(USE_TAB_CHAR, value);
};

/** @type {boolean} Gets whether the current editor uses tab characters (vs. spaces) when inserting new text */
Expand All @@ -1613,7 +1616,7 @@ define(function (require, exports, module) {
* @param {number} value
*/
Editor.setTabSize = function (value) {
PreferencesManager.setValueAndSave(TAB_SIZE, value);
PreferencesManager.set(TAB_SIZE, value);
};

/** @type {number} Get indent unit */
Expand All @@ -1627,7 +1630,7 @@ define(function (require, exports, module) {
* @param {number} value
*/
Editor.setSpaceUnits = function (value) {
PreferencesManager.setValueAndSave(SPACE_UNITS, value);
PreferencesManager.set(SPACE_UNITS, value);
};

/** @type {number} Get indentation width */
Expand All @@ -1641,7 +1644,7 @@ define(function (require, exports, module) {
* @param {boolean} value
*/
Editor.setCloseBrackets = function (value) {
PreferencesManager.setValueAndSave(CLOSE_BRACKETS, value);
PreferencesManager.set(CLOSE_BRACKETS, value);
};

/** @type {boolean} Gets whether the current editor uses auto close brackets */
Expand All @@ -1655,7 +1658,7 @@ define(function (require, exports, module) {
* @param {boolean} value
*/
Editor.setShowLineNumbers = function (value) {
PreferencesManager.setValueAndSave(SHOW_LINE_NUMBERS, value);
PreferencesManager.set(SHOW_LINE_NUMBERS, value);
};

/** @type {boolean} Returns true if show line numbers is enabled for the current editor */
Expand Down
5 changes: 3 additions & 2 deletions src/extensibility/InstallExtensionDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ define(function (require, exports, module) {

var context = {
Strings: Strings,
isUpdate: this._isUpdate
isUpdate: this._isUpdate,
includeBrowseExtensions: !!brackets.config.extension_listing_url
};

// We ignore the promise returned by showModalDialogUsingTemplate, since we're managing the
Expand All @@ -352,7 +353,7 @@ define(function (require, exports, module) {
this.$cancelButton.on("click", this._handleCancel.bind(this));
this.$url.on("input", this._handleUrlInput.bind(this));
this.$browseExtensionsButton.on("click", function () {
NativeApp.openURLInDefaultBrowser(brackets.config.extension_wiki_url);
NativeApp.openURLInDefaultBrowser(brackets.config.extension_listing_url);
});
$(document.body).on("keyup.installDialog", this._handleKeyUp.bind(this));

Expand Down
7 changes: 5 additions & 2 deletions src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ define(function (require, exports, module) {
StringUtils = require("utils/StringUtils"),
Strings = require("strings"),
ExtensionLoader = require("utils/ExtensionLoader"),
NodeConnection = require("utils/NodeConnection");
NodeConnection = require("utils/NodeConnection"),
PreferencesManager = require("preferences/PreferencesManager");

PreferencesManager.definePreference("proxy", "string");

var Errors = {
ERROR_LOADING: "ERROR_LOADING",
Expand Down Expand Up @@ -246,7 +249,7 @@ define(function (require, exports, module) {
}

// Download the bits (using Node since brackets-shell doesn't support binary file IO)
var r = extensionManager.downloadFile(downloadId, urlInfo.url);
var r = extensionManager.downloadFile(downloadId, urlInfo.url, PreferencesManager.get("proxy"));
r.done(function (result) {
d.resolve({ localPath: result, filenameHint: urlInfo.filenameHint });
}).fail(function (err) {
Expand Down
Loading

0 comments on commit 870a9ef

Please sign in to comment.