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 'origin/master' into pflynn/unit-test-cl…
Browse files Browse the repository at this point in the history
…eanups

* origin/master: (30 commits)
  turn off optimization in acorn (but not acorn_loose right now)
  cleanup unit test prefs
  temporarily switch to my tern
  Revert "Revert "Workaround for the Tern crash.""
  Update README.md
  Work around #4554 (Extension Manager font is hard to read on Windows), which is a Chromium bug, by avoiding the lightest font-weight on Win. Lighten the text slightly so it's still a little muted, like the design looks on Mac and with older CEFs on Win.
  Revert "Workaround for the Tern crash."
  Updated by ALF automation.
  Re-add toolbar hover. Fix some button appearance issues.
  Updated by ALF automation.
  * Fix bug #4548 - remove Save As from folder tree context menu * Fix exception thrown when File > Save As invoked with nothing open * Update docs for working set events to reflect PR #4450
  integration tests for registerInlineEditProvider
  Fixes after review
  JSDoc fixes.
  Fix for extensions compare
  show error message and add safety check
  For #4535, show error message but not 'remove' link for bad extension in dev folder
  Refactor provider callback for export
  Generalize registerInlineEditProvider and registerInlineDocProvider to take an optional priority parameter
  change upper limit to 16000
  ...
  • Loading branch information
peterflynn committed Jul 30, 2013
2 parents 7250b96 + c211ba5 commit 8d94d0d
Show file tree
Hide file tree
Showing 35 changed files with 718 additions and 413 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
url = https://github.com/janl/mustache.js.git
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/tern"]
path = src/extensions/default/JavaScriptCodeHints/thirdparty/tern
url = https://github.com/marijnh/tern.git
url = https://github.com/dangoor/tern.git
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/acorn"]
path = src/extensions/default/JavaScriptCodeHints/thirdparty/acorn
url = https://github.com/marijnh/acorn.git
url = https://github.com/dangoor/acorn.git
[submodule "src/thirdparty/requirejs"]
path = src/thirdparty/requirejs
url = https://github.com/jrburke/requirejs.git
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and JavaScript, you can [help build](https://github.com/adobe/brackets/blob/mast

You can see some
[screenshots of Brackets](https://github.com/adobe/brackets/wiki/Brackets-Screenshots)
on the wiki, [intro videos](http://www.youtube.com/user/CodeBrackets) on YouTube, and news on the [Brackets' blog](http://blog.brackets.io/).
on the wiki, [intro videos](http://www.youtube.com/user/CodeBrackets) on YouTube, and news on the [Brackets blog](http://blog.brackets.io/).


How to install and run Brackets
Expand Down
1 change: 0 additions & 1 deletion src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ define(function (require, exports, module) {
project_cmenu.addMenuItem(Commands.FILE_NEW);
project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER);
project_cmenu.addMenuItem(Commands.FILE_RENAME);
project_cmenu.addMenuItem(Commands.FILE_SAVE_AS);
project_cmenu.addMenuItem(Commands.FILE_DELETE);
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
project_cmenu.addMenuDivider();
Expand Down
15 changes: 8 additions & 7 deletions src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,19 @@ define(function (require, exports, module) {
function handleFileSaveAs(commandData) {
// Default to current document if doc is null
var doc = null,
activeEditor,
settings;

if (commandData) {
doc = commandData.doc;
} else {
activeEditor = EditorManager.getActiveEditor();
doc = activeEditor.document;
settings = {};
settings.selection = activeEditor.getSelection();
settings.cursorPos = activeEditor.getCursorPos();
settings.scrollPos = activeEditor.getScrollPos();
var activeEditor = EditorManager.getActiveEditor();
if (activeEditor) {
doc = activeEditor.document;
settings = {};
settings.selection = activeEditor.getSelection();
settings.cursorPos = activeEditor.getCursorPos();
settings.scrollPos = activeEditor.getScrollPos();
}
}

// doc may still be null, e.g. if no editors are open, but _doSaveAs() does a null check on
Expand Down
21 changes: 13 additions & 8 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,20 @@
* 2nd arg to the listener is the removed FileEntry.
* - workingSetRemoveList -- When multiple files are removed from the working set (e.g. project close).
* The 2nd arg to the listener is the array of removed FileEntry objects.
* - workingSetSort -- When the workingSet array is sorted. Notifies the working set view to redraw
* the new sorted list. Listener receives no arguments.
* - workingSetDisableAutoSorting -- When working set is manually re-sorted via dragging and dropping
* a file to disable automatic sorting. Listener receives no arguments.
* - workingSetSort -- When the workingSet array is reordered without additions or removals.
* Listener receives no arguments.
*
* - workingSetDisableAutoSorting -- Dispatched in addition to workingSetSort when the reorder was caused
* by manual dragging and dropping. Listener receives no arguments.
*
* - fileNameChange -- When the name of a file or folder has changed. The 2nd arg is the old name.
* The 3rd arg is the new name.
* - pathDeleted -- When a file or folder has been deleted. The 2nd arg is the path that was deleted.
*
* These are jQuery events, so to listen for them you do something like this:
* $(DocumentManager).on("eventname", handler);
*
* Document objects themselves also dispatch some events - see Document docs for details.
*/
define(function (require, exports, module) {
"use strict";
Expand Down Expand Up @@ -367,8 +370,8 @@ define(function (require, exports, module) {

/**
* Mutually exchanges the files at the indexes passed by parameters.
* @param {!number} index - old file index
* @param {!number} index - new file index
* @param {number} index Old file index
* @param {number} index New file index
*/
function swapWorkingSetIndexes(index1, index2) {
var length = _workingSet.length - 1;
Expand All @@ -378,13 +381,15 @@ define(function (require, exports, module) {
temp = _workingSet[index1];
_workingSet[index1] = _workingSet[index2];
_workingSet[index2] = temp;

$(exports).triggerHandler("workingSetSort");
$(exports).triggerHandler("workingSetDisableAutoSorting");
}
}

/**
* Sorts _workingSet using the compare function
* @param {!function(FileEntry, FileEntry)} compareFn - the function that will be used inside JavaScript's
* @param {function(FileEntry, FileEntry): number} compareFn The function that will be used inside JavaScript's
* sort function. The return a value should be >0 (sort a to a lower index than b), =0 (leaves a and b
* unchanged with respect to each other) or <0 (sort b to a lower index than a) and must always returns
* the same value when given a specific pair of elements a and b as its two arguments.
Expand Down Expand Up @@ -422,7 +427,7 @@ define(function (require, exports, module) {
/**
* Get the next or previous file in the working set, in MRU order (relative to currentDocument). May
* return currentDocument itself if working set is length 1.
* @param {Number} inc -1 for previous, +1 for next; no other values allowed
* @param {number} inc -1 for previous, +1 for next; no other values allowed
* @return {?FileEntry} null if working set empty
*/
function getNextPrevFile(inc) {
Expand Down
65 changes: 52 additions & 13 deletions src/editor/EditorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ define(function (require, exports, module) {
var _lastEditorWidth = null;

/**
* Registered inline-editor widget providers. See {@link #registerInlineEditProvider()}.
* @type {Array.<function(...)>}
* Registered inline-editor widget providers sorted descending by priority.
* See {@link #registerInlineEditProvider()}.
* @type {Array.<{priority:number, provider:function(...)}>}
*/
var _inlineEditProviders = [];

/**
* Registered inline documentation widget providers. See {@link #registerInlineDocsProvider()}.
* @type {Array.<function(...)>}
* Registered inline documentation widget providers sorted descending by priority.
* See {@link #registerInlineDocsProvider()}.
* @type {Array.<{priority:number, provider:function(...)}>}
*/
var _inlineDocsProviders = [];

Expand Down Expand Up @@ -149,7 +151,7 @@ define(function (require, exports, module) {
* Finds an inline widget provider from the given list that can offer a widget for the current cursor
* position, and once the widget has been created inserts it into the editor.
* @param {!Editor} editor The host editor
* @param {!Array.<function(!Editor, !{line:Number, ch:Number}):?$.Promise>} providers
* @param {!Array.<{priority:number, provider:function(!Editor, !{line:number, ch:number}):?$.Promise}>} prioritized providers
* @return {$.Promise} a promise that will be resolved when an InlineWidget
* is created or rejected if no inline providers have offered one.
*/
Expand All @@ -163,7 +165,7 @@ define(function (require, exports, module) {
result = new $.Deferred();

for (i = 0; i < providers.length && !inlinePromise; i++) {
var provider = providers[i];
var provider = providers[i].provider;
inlinePromise = provider(editor, pos);
}

Expand All @@ -188,6 +190,29 @@ define(function (require, exports, module) {
return result.promise();
}

/**
* Inserts a prioritized provider object into the array in sorted (descending) order.
*
* @param {Array.<{priority:number, provider:function(...)}>} array
* @param {number} priority
* @param {function(...)} provider
*/
function _insertProviderSorted(array, provider, priority) {
var index,
prioritizedProvider = {
priority: priority,
provider: provider
};

for (index = 0; index < array.length; index++) {
if (array[index].priority < priority) {
break;
}
}

array.splice(index, 0, prioritizedProvider);
}

/**
* Removes the given widget UI from the given hostEditor (agnostic of what the widget's content
* is). The widget's onClosed() callback will be run as a result.
Expand Down Expand Up @@ -215,32 +240,44 @@ define(function (require, exports, module) {
/**
* Registers a new inline editor provider. When Quick Edit is invoked each registered provider is
* asked if it wants to provide an inline editor given the current editor and cursor location.
* An optional priority parameter is used to give providers with higher priority an opportunity
* to provide an inline editor before providers with lower priority.
*
* @param {function(!Editor, !{line:Number, ch:Number}):?$.Promise} provider
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
* @param {number=} priority
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
* to indicate the provider doesn't want to respond to this case.
*/
function registerInlineEditProvider(provider) {
_inlineEditProviders.push(provider);
function registerInlineEditProvider(provider, priority) {
if (priority === undefined) {
priority = 0;
}
_insertProviderSorted(_inlineEditProviders, provider, priority);
}

/**
* Registers a new inline docs provider. When Quick Docs is invoked each registered provider is
* asked if it wants to provide inline docs given the current editor and cursor location.
* An optional priority parameter is used to give providers with higher priority an opportunity
* to provide an inline editor before providers with lower priority.
*
* @param {function(!Editor, !{line:Number, ch:Number}):?$.Promise} provider
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
* @param {number=} priority
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
* to indicate the provider doesn't want to respond to this case.
*/
function registerInlineDocsProvider(provider) {
_inlineDocsProviders.push(provider);
function registerInlineDocsProvider(provider, priority) {
if (priority === undefined) {
priority = 0;
}
_insertProviderSorted(_inlineDocsProviders, provider, priority);
}

/**
* Registers a new jump-to-definition provider. When jump-to-definition is invoked each
* registered provider is asked if it wants to provide jump-to-definition results, given
* the current editor and cursor location.
* @param {function(!Editor, !{line:Number, ch:Number}):?$.Promise} provider
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
* The provider returns a promise that will be resolved with jump-to-definition results, or
* returns null to indicate the provider doesn't want to respond to this case.
*/
Expand Down Expand Up @@ -662,6 +699,8 @@ define(function (require, exports, module) {

/**
* Closes any focused inline widget. Else, asynchronously asks providers to create one.
*
* @param {Array.<{priority:number, provider:function(...)}>} prioritized providers
* @return {!Promise} A promise resolved with true if an inline widget is opened or false
* when closed. Rejected if there is neither an existing widget to close nor a provider
* willing to create a widget (or if no editor is open).
Expand Down
Loading

0 comments on commit 8d94d0d

Please sign in to comment.