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

Commit

Permalink
Merge pull request #2685 from WebsiteDeveloper/issue#1997
Browse files Browse the repository at this point in the history
Fixed: #1997 and #1397
  • Loading branch information
dangoor committed Jan 29, 2013
2 parents 02d5310 + 5747e8c commit 2433046
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/LiveDevelopment/Agents/RemoteAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ define(function RemoteAgent(require, exports, module) {
args[i] = args[i].resolve();
}
}
$.when.apply(undefined, args).then(function onResolvedAllNodes() {
$.when.apply(undefined, args).done(function onResolvedAllNodes() {
var i, arg, params = [];
for (i in arguments) {
arg = args[i];
Expand Down Expand Up @@ -131,4 +131,4 @@ define(function RemoteAgent(require, exports, module) {
exports.call = call;
exports.load = load;
exports.unload = unload;
});
});
10 changes: 5 additions & 5 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ define(function LiveDevelopment(require, exports, module) {
// Load agents
_setStatus(STATUS_LOADING_AGENTS);
var promises = loadAgents();
$.when.apply(undefined, promises).then(_onLoad, _onError);
$.when.apply(undefined, promises).done(_onLoad).fail(_onError);

// Load the right document (some agents are waiting for the page's load event)
var doc = _getCurrentDocument();
Expand All @@ -457,7 +457,7 @@ define(function LiveDevelopment(require, exports, module) {
unloadAgents();
var promises = loadAgents();
_setStatus(STATUS_LOADING_AGENTS);
$.when.apply(undefined, promises).then(_onLoad, _onError);
$.when.apply(undefined, promises).done(_onLoad).fail(_onError);
}

/** Open the Connection and go live */
Expand Down Expand Up @@ -512,7 +512,7 @@ define(function LiveDevelopment(require, exports, module) {
var url = doc.root.url;

_setStatus(STATUS_CONNECTING);
Inspector.connectToURL(url).then(result.resolve, function onConnectFail(err) {
Inspector.connectToURL(url).done(result.resolve).fail(function onConnectFail(err) {
if (err === "CANCEL") {
result.reject(err);
return;
Expand All @@ -531,7 +531,7 @@ define(function LiveDevelopment(require, exports, module) {
.done(function () {
browserStarted = false;
window.setTimeout(function () {
open().then(result.resolve, result.reject);
open().done(result.resolve).fail(result.reject);
});
})
.fail(function (err) {
Expand Down Expand Up @@ -591,7 +591,7 @@ define(function LiveDevelopment(require, exports, module) {

if (exports.status !== STATUS_ERROR) {
window.setTimeout(function retryConnect() {
Inspector.connectToURL(url).then(result.resolve, onConnectFail);
Inspector.connectToURL(url).done(result.resolve).fail(onConnectFail);
}, 500);
}
});
Expand Down
6 changes: 1 addition & 5 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,10 @@ define(function (require, exports, module) {
* @param {!string} mode Syntax-highlighting language mode; "" means plain-text mode.
* See {@link EditorUtils#getModeFromFileExtension()}.
* @param {!jQueryObject} container Container to add the editor to.
* @param {!Object<string, function(Editor)>} additionalKeys Mapping of keyboard shortcuts to
* custom handler functions. Mapping is in CodeMirror format
* @param {{startLine: number, endLine: number}=} range If specified, range of lines within the document
* to display in this editor. Inclusive.
*/
function Editor(document, makeMasterEditor, mode, container, additionalKeys, range) {
function Editor(document, makeMasterEditor, mode, container, range) {
var self = this;

_instances.push(this);
Expand Down Expand Up @@ -332,8 +330,6 @@ define(function (require, exports, module) {
"'/'": function (cm) { cm.closeTag(cm, '/'); }
};

EditorManager.mergeExtraKeys(self, codeMirrorKeyMap, additionalKeys);

// We'd like null/"" to mean plain text mode. CodeMirror defaults to plaintext for any
// unrecognized mode, but it complains on the console in that fallback case: so, convert
// here so we're always explicit, avoiding console noise.
Expand Down
33 changes: 4 additions & 29 deletions src/editor/EditorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,6 @@ define(function (require, exports, module) {
$indentWidthLabel,
$indentWidthInput;

/**
* Adds keyboard command handlers to an Editor instance.
* @param {Editor} editor
* @param {!Object.<string,function(Editor)>} to destination key mapping
* @param {!Object.<string,function(Editor)>} from source key mapping
*/
function mergeExtraKeys(editor, to, from) {
// Merge in the additionalKeys we were passed
function wrapEventHandler(externalHandler) {
return function (instance) {
externalHandler(editor);
};
}
var key;
for (key in from) {
if (from.hasOwnProperty(key)) {
if (to.hasOwnProperty(key)) {
console.log("Warning: overwriting standard Editor shortcut " + key);
}
to[key] = (editor !== null) ? wrapEventHandler(from[key]) : from[key];
}
}
}

/**
* Creates a new Editor bound to the given Document. The editor's mode is inferred based on the
* file extension. The editor is appended to the given container as a visible child.
Expand All @@ -132,10 +108,10 @@ define(function (require, exports, module) {
* to display in this editor. Inclusive.
* @return {Editor} the newly created editor.
*/
function _createEditorForDocument(doc, makeMasterEditor, container, range, additionalKeys) {
function _createEditorForDocument(doc, makeMasterEditor, container, range) {
var mode = EditorUtils.getModeFromFileExtension(doc.file.fullPath);

return new Editor(doc, makeMasterEditor, mode, container, additionalKeys, range);
return new Editor(doc, makeMasterEditor, mode, container, range);
}

/**
Expand Down Expand Up @@ -275,9 +251,9 @@ define(function (require, exports, module) {
*
* @return {{content:DOMElement, editor:Editor}}
*/
function createInlineEditorForDocument(doc, range, inlineContent, additionalKeys) {
function createInlineEditorForDocument(doc, range, inlineContent) {
// Create the Editor
var inlineEditor = _createEditorForDocument(doc, false, inlineContent, range, additionalKeys);
var inlineEditor = _createEditorForDocument(doc, false, inlineContent, range);

return { content: inlineContent, editor: inlineEditor };
}
Expand Down Expand Up @@ -812,5 +788,4 @@ define(function (require, exports, module) {
exports.registerInlineEditProvider = registerInlineEditProvider;
exports.getInlineEditors = getInlineEditors;
exports.closeInlineWidget = closeInlineWidget;
exports.mergeExtraKeys = mergeExtraKeys;
});
4 changes: 2 additions & 2 deletions src/editor/InlineTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ define(function (require, exports, module) {
* @param {number} endLine of text to show in inline editor
* @param {HTMLDivElement} container container to hold the inline editor
*/
InlineTextEditor.prototype.createInlineEditorFromText = function (doc, startLine, endLine, container, additionalKeys) {
InlineTextEditor.prototype.createInlineEditorFromText = function (doc, startLine, endLine, container) {
var self = this;

var range = {
Expand Down Expand Up @@ -250,7 +250,7 @@ define(function (require, exports, module) {


// Create actual Editor instance
var inlineInfo = EditorManager.createInlineEditorForDocument(doc, range, wrapperDiv, additionalKeys);
var inlineInfo = EditorManager.createInlineEditorForDocument(doc, range, wrapperDiv);
this.editors.push(inlineInfo.editor);
container.appendChild(wrapperDiv);

Expand Down
4 changes: 2 additions & 2 deletions src/extensions/default/HTMLCodeHints/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ define(function (require, exports, module) {

// create Editor instance (containing a CodeMirror instance)
$("body").append("<div id='editor'/>");
testEditor = new Editor(testDocument, true, "htmlmixed", $("#editor").get(0), {});
testEditor = new Editor(testDocument, true, "htmlmixed", $("#editor").get(0));
});

afterEach(function () {
Expand Down Expand Up @@ -640,4 +640,4 @@ define(function (require, exports, module) {


}); // describe("HTML Attribute Hinting"
});
});
7 changes: 3 additions & 4 deletions src/file/NativeFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,7 @@ define(function (require, exports, module) {
var timeoutWrapper = Async.withTimeout(masterPromise, NativeFileSystem.ASYNC_TIMEOUT);

// Add the callbacks to this top-level Promise, which wraps all the individual deferred objects
timeoutWrapper.then(
function () { // success
timeoutWrapper.done(function () { // success
// The entries array may have null values if stat returned things that were
// neither a file nor a dir. So, we need to clean those out.
var cleanedEntries = [], i;
Expand All @@ -1000,8 +999,8 @@ define(function (require, exports, module) {
}
}
successCallback(cleanedEntries);
},
function (err) { // error
})
.fail(function (err) { // error
if (err === Async.ERROR_TIMEOUT) {
// SECURITY_ERR is the HTML5 File catch-all error, and there isn't anything
// more fitting for a timeout.
Expand Down
2 changes: 1 addition & 1 deletion test/spec/CodeHintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define(function (require, exports, module) {
// init Editor instance (containing a CodeMirror instance)
$("body").append("<div id='editor'/>");
myDocument = SpecRunnerUtils.createMockDocument("");
myEditor = new Editor(myDocument, true, "", $("#editor").get(0), {});
myEditor = new Editor(myDocument, true, "", $("#editor").get(0));
});

afterEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/SpecRunnerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ define(function (require, exports, module) {
var doc = createMockDocument(initialContent);

// create Editor instance
var editor = new Editor(doc, true, mode, $editorHolder.get(0), {}, visibleRange);
var editor = new Editor(doc, true, mode, $editorHolder.get(0), visibleRange);

return { doc: doc, editor: editor };
}
Expand Down

0 comments on commit 2433046

Please sign in to comment.