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

Commit 8d94d0d

Browse files
committed
Merge remote-tracking branch 'origin/master' into pflynn/unit-test-cleanups
* 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 ...
2 parents 7250b96 + c211ba5 commit 8d94d0d

35 files changed

+718
-413
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
url = https://github.com/janl/mustache.js.git
1313
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/tern"]
1414
path = src/extensions/default/JavaScriptCodeHints/thirdparty/tern
15-
url = https://github.com/marijnh/tern.git
15+
url = https://github.com/dangoor/tern.git
1616
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/acorn"]
1717
path = src/extensions/default/JavaScriptCodeHints/thirdparty/acorn
18-
url = https://github.com/marijnh/acorn.git
18+
url = https://github.com/dangoor/acorn.git
1919
[submodule "src/thirdparty/requirejs"]
2020
path = src/thirdparty/requirejs
2121
url = https://github.com/jrburke/requirejs.git

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and JavaScript, you can [help build](https://github.com/adobe/brackets/blob/mast
1717

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

2222

2323
How to install and run Brackets

src/command/DefaultMenus.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ define(function (require, exports, module) {
183183
project_cmenu.addMenuItem(Commands.FILE_NEW);
184184
project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER);
185185
project_cmenu.addMenuItem(Commands.FILE_RENAME);
186-
project_cmenu.addMenuItem(Commands.FILE_SAVE_AS);
187186
project_cmenu.addMenuItem(Commands.FILE_DELETE);
188187
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
189188
project_cmenu.addMenuDivider();

src/document/DocumentCommandHandlers.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -760,18 +760,19 @@ define(function (require, exports, module) {
760760
function handleFileSaveAs(commandData) {
761761
// Default to current document if doc is null
762762
var doc = null,
763-
activeEditor,
764763
settings;
765764

766765
if (commandData) {
767766
doc = commandData.doc;
768767
} else {
769-
activeEditor = EditorManager.getActiveEditor();
770-
doc = activeEditor.document;
771-
settings = {};
772-
settings.selection = activeEditor.getSelection();
773-
settings.cursorPos = activeEditor.getCursorPos();
774-
settings.scrollPos = activeEditor.getScrollPos();
768+
var activeEditor = EditorManager.getActiveEditor();
769+
if (activeEditor) {
770+
doc = activeEditor.document;
771+
settings = {};
772+
settings.selection = activeEditor.getSelection();
773+
settings.cursorPos = activeEditor.getCursorPos();
774+
settings.scrollPos = activeEditor.getScrollPos();
775+
}
775776
}
776777

777778
// doc may still be null, e.g. if no editors are open, but _doSaveAs() does a null check on

src/document/DocumentManager.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@
7070
* 2nd arg to the listener is the removed FileEntry.
7171
* - workingSetRemoveList -- When multiple files are removed from the working set (e.g. project close).
7272
* The 2nd arg to the listener is the array of removed FileEntry objects.
73-
* - workingSetSort -- When the workingSet array is sorted. Notifies the working set view to redraw
74-
* the new sorted list. Listener receives no arguments.
75-
* - workingSetDisableAutoSorting -- When working set is manually re-sorted via dragging and dropping
76-
* a file to disable automatic sorting. Listener receives no arguments.
73+
* - workingSetSort -- When the workingSet array is reordered without additions or removals.
74+
* Listener receives no arguments.
75+
*
76+
* - workingSetDisableAutoSorting -- Dispatched in addition to workingSetSort when the reorder was caused
77+
* by manual dragging and dropping. Listener receives no arguments.
7778
*
7879
* - fileNameChange -- When the name of a file or folder has changed. The 2nd arg is the old name.
7980
* The 3rd arg is the new name.
8081
* - pathDeleted -- When a file or folder has been deleted. The 2nd arg is the path that was deleted.
8182
*
8283
* These are jQuery events, so to listen for them you do something like this:
8384
* $(DocumentManager).on("eventname", handler);
85+
*
86+
* Document objects themselves also dispatch some events - see Document docs for details.
8487
*/
8588
define(function (require, exports, module) {
8689
"use strict";
@@ -367,8 +370,8 @@ define(function (require, exports, module) {
367370

368371
/**
369372
* Mutually exchanges the files at the indexes passed by parameters.
370-
* @param {!number} index - old file index
371-
* @param {!number} index - new file index
373+
* @param {number} index Old file index
374+
* @param {number} index New file index
372375
*/
373376
function swapWorkingSetIndexes(index1, index2) {
374377
var length = _workingSet.length - 1;
@@ -378,13 +381,15 @@ define(function (require, exports, module) {
378381
temp = _workingSet[index1];
379382
_workingSet[index1] = _workingSet[index2];
380383
_workingSet[index2] = temp;
384+
385+
$(exports).triggerHandler("workingSetSort");
381386
$(exports).triggerHandler("workingSetDisableAutoSorting");
382387
}
383388
}
384389

385390
/**
386391
* Sorts _workingSet using the compare function
387-
* @param {!function(FileEntry, FileEntry)} compareFn - the function that will be used inside JavaScript's
392+
* @param {function(FileEntry, FileEntry): number} compareFn The function that will be used inside JavaScript's
388393
* sort function. The return a value should be >0 (sort a to a lower index than b), =0 (leaves a and b
389394
* unchanged with respect to each other) or <0 (sort b to a lower index than a) and must always returns
390395
* the same value when given a specific pair of elements a and b as its two arguments.
@@ -422,7 +427,7 @@ define(function (require, exports, module) {
422427
/**
423428
* Get the next or previous file in the working set, in MRU order (relative to currentDocument). May
424429
* return currentDocument itself if working set is length 1.
425-
* @param {Number} inc -1 for previous, +1 for next; no other values allowed
430+
* @param {number} inc -1 for previous, +1 for next; no other values allowed
426431
* @return {?FileEntry} null if working set empty
427432
*/
428433
function getNextPrevFile(inc) {

src/editor/EditorManager.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ define(function (require, exports, module) {
9090
var _lastEditorWidth = null;
9191

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

9899
/**
99-
* Registered inline documentation widget providers. See {@link #registerInlineDocsProvider()}.
100-
* @type {Array.<function(...)>}
100+
* Registered inline documentation widget providers sorted descending by priority.
101+
* See {@link #registerInlineDocsProvider()}.
102+
* @type {Array.<{priority:number, provider:function(...)}>}
101103
*/
102104
var _inlineDocsProviders = [];
103105

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

165167
for (i = 0; i < providers.length && !inlinePromise; i++) {
166-
var provider = providers[i];
168+
var provider = providers[i].provider;
167169
inlinePromise = provider(editor, pos);
168170
}
169171

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

193+
/**
194+
* Inserts a prioritized provider object into the array in sorted (descending) order.
195+
*
196+
* @param {Array.<{priority:number, provider:function(...)}>} array
197+
* @param {number} priority
198+
* @param {function(...)} provider
199+
*/
200+
function _insertProviderSorted(array, provider, priority) {
201+
var index,
202+
prioritizedProvider = {
203+
priority: priority,
204+
provider: provider
205+
};
206+
207+
for (index = 0; index < array.length; index++) {
208+
if (array[index].priority < priority) {
209+
break;
210+
}
211+
}
212+
213+
array.splice(index, 0, prioritizedProvider);
214+
}
215+
191216
/**
192217
* Removes the given widget UI from the given hostEditor (agnostic of what the widget's content
193218
* is). The widget's onClosed() callback will be run as a result.
@@ -215,32 +240,44 @@ define(function (require, exports, module) {
215240
/**
216241
* Registers a new inline editor provider. When Quick Edit is invoked each registered provider is
217242
* asked if it wants to provide an inline editor given the current editor and cursor location.
243+
* An optional priority parameter is used to give providers with higher priority an opportunity
244+
* to provide an inline editor before providers with lower priority.
218245
*
219-
* @param {function(!Editor, !{line:Number, ch:Number}):?$.Promise} provider
246+
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
247+
* @param {number=} priority
220248
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
221249
* to indicate the provider doesn't want to respond to this case.
222250
*/
223-
function registerInlineEditProvider(provider) {
224-
_inlineEditProviders.push(provider);
251+
function registerInlineEditProvider(provider, priority) {
252+
if (priority === undefined) {
253+
priority = 0;
254+
}
255+
_insertProviderSorted(_inlineEditProviders, provider, priority);
225256
}
226257

227258
/**
228259
* Registers a new inline docs provider. When Quick Docs is invoked each registered provider is
229260
* asked if it wants to provide inline docs given the current editor and cursor location.
261+
* An optional priority parameter is used to give providers with higher priority an opportunity
262+
* to provide an inline editor before providers with lower priority.
230263
*
231-
* @param {function(!Editor, !{line:Number, ch:Number}):?$.Promise} provider
264+
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
265+
* @param {number=} priority
232266
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
233267
* to indicate the provider doesn't want to respond to this case.
234268
*/
235-
function registerInlineDocsProvider(provider) {
236-
_inlineDocsProviders.push(provider);
269+
function registerInlineDocsProvider(provider, priority) {
270+
if (priority === undefined) {
271+
priority = 0;
272+
}
273+
_insertProviderSorted(_inlineDocsProviders, provider, priority);
237274
}
238275

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

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

0 commit comments

Comments
 (0)