Merge pull request #4254 from eztierney/iss-3863

Fix Issue #3863 - jump-to-def goes to exports line.
This commit is contained in:
dloverin committed 2013-06-17 13:26:40 -07:00
commit 893b3bd29d
6 files changed
+211 -42

No files matched your search

@@ -292,13 +292,18 @@ define(function (require, exports, module) {
* @param {{line:number, ch:number}} oldLocation - the original line/col
* @param {Function} callback - the callback to apply once the editor has changed position
*/
function _waitForJump(oldLocation, callback) {
var cursor = null;
function _waitForJump(jumpPromise, callback) {
var cursor = null,
complete = false;
jumpPromise.done(function () {
complete = true;
});
waitsFor(function () {
var activeEditor = EditorManager.getActiveEditor();
cursor = activeEditor.getCursorPos();
return (cursor.line !== oldLocation.line) ||
(cursor.ch !== oldLocation.ch);
return complete;
}, "Expected jump did not occur", 3000);
runs(function () { callback(cursor); });
@@ -315,10 +320,10 @@ define(function (require, exports, module) {
function editorJumped(expectedLocation) {
var oldLocation = testEditor.getCursorPos();
JSCodeHints.handleJumpToDefinition();
var jumpPromise = JSCodeHints.handleJumpToDefinition();
_waitForJump(oldLocation, function (newCursor) {
_waitForJump(jumpPromise, function (newCursor) {
expect(newCursor.line).toBe(expectedLocation.line);
expect(newCursor.ch).toBe(expectedLocation.ch);
if (expectedLocation.file) {
@@ -740,7 +745,7 @@ define(function (require, exports, module) {
testEditor.setCursorPos(start);
var hintObj = expectHints(JSCodeHints.jsHintProvider);
runs(function () {
hintsPresentExact(hintObj, ["a", "b", "j"]);
hintsPresentExact(hintObj, ["a", "b", "c", "j"]);
});
});
@@ -999,7 +1004,7 @@ define(function (require, exports, module) {
editorJumped({line: 4, ch: 13, file: "MyModule.js"}); //jump to another file
});
});
it("should jump to the method definition in .prototype", function () {
var start = { line: 59, ch: 8 };
@@ -1036,6 +1041,15 @@ define(function (require, exports, module) {
});
});
it("should jump to the actual function definition, and not the exports line", function () {
var start = { line: 159, ch: 22 };
testEditor.setCursorPos(start);
runs(function () {
editorJumped({line: 11, ch: 14, file: "MyModule.js"}); //jump to another file
});
});
it("should not hint function, variable, or param decls", function () {
var func = { line: 7, ch: 12 },
param = { line: 7, ch: 18 },